Windows Vista Forums
Vista Forums Home Join Vista Forums Donate 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 Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

How to print out the contents of reader for SQL

Reply
 
LinkBack Thread Tools Display Modes
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
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Vista Can't Print to Win2K shared printer-Test Print disappears fr Jeremy Vista networking & sharing 2 06-29-2008 02:31 PM
Unable to Print or Print Preview from IE7 on Vista Home Premium Poppy Vista print fax & scan 8 05-13-2008 01:56 AM
After printing several documents, the print queue hangs, print st FredJ Vista print fax & scan 3 04-19-2008 04:33 PM
HOw do I start the print spooler so I can install my print drivers? jaczar Vista installation & setup 3 12-17-2007 08:42 PM
Acrobat reader crashes when trying to print cindywads Vista print fax & scan 0 11-21-2007 11:41 PM


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 47 48 49 50 51 52 53