Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista Tutorial - How to print out the contents of reader for SQL

Reply
 
Old 08-07-2007   #1 (permalink)
Frank
Guest


 
 

How to print out the contents of reader for SQL

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
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
Reply

Thread Tools


Similar Threads
Thread Forum
Does the Hp6730s laptop has finger print reader/scanner?? Drivers
Print Folder Contents Vista General
Vista Can't Print to Win2K shared printer-Test Print disappears fr Vista networking & sharing
Unable to Print or Print Preview from IE7 on Vista Home Premium Vista print fax & scan
Acrobat reader crashes when trying to print Vista print fax & scan


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46