View Single Post
Old 08-07-2007   #2 (permalink)
Frank
Guest


 
 

RE: How to print out the contents of reader for SQL

I guess, I can do this:

$cmd.CommandText=" SELECT @@Version as version"

$rdr = $cmd.ExecuteReader()
While($rdr.Read()){
$version = $rdr['version']
}
$conn.Close()
$version



"Frank" wrote:

> Hi,
>
> I am trying to get the output of reader for get the version of sqlserver.
> Can someone help me with this?
>
> Thanks,
>
> $conn = new-object System.Data.SqlClient.SqlConnection
> $conn.ConnectionString = "server=testserver;integrated
> security=true;database=test"
> $conn.Open()
> $cmd = new-object System.Data.SqlClient.SqlCommand
> $cmd.CommandText="SELECT @@VERSION"
>
> $cmd.Connection=$conn
> $rdr = $cmd.ExecuteReader()
>

My System SpecsSystem Spec