Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $sqlcon = New-Object System.Data.SqlClient.SqlConnection
- $sqlcon.ConnectionString = "Data Source=mysqlserver\myinstance1; Initial Catalog=blah; uid=hans; pwd=wurst" # integratedsecurity=true for domainusers
- $sqlcmd = New-Object System.Data.SqlClient.SqlCommand
- $sqlcmd.Connection = $sqlcon
- $sqlcmd.CommandText = "select top 20 rowname FROM tablename"
- $sqlcon.Open()
- $sqlds = New-Object System.Data.DataSet
- $sqlda = New-Object System.Data.SqlClient.SqlDataAdapter ($sqlcmd)
- [void]$sqlda.fill($sqlds)
- $sqlcon.Close()
- $sqlds.Tables
- write-host "-- we have" $sqlds.Tables[0].row.count "rows"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement