Skip to content

Instantly share code, notes, and snippets.

@ATLPhenx
Created April 27, 2016 18:04
Show Gist options
  • Save ATLPhenx/8b7c19bcacd7cfc06b0abcc29a1f5e01 to your computer and use it in GitHub Desktop.
Save ATLPhenx/8b7c19bcacd7cfc06b0abcc29a1f5e01 to your computer and use it in GitHub Desktop.
$conn = New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = $connectionString
$cmd = New-Object System.Data.SqlClient.SqlCommand
$cmd.commandtext = $query
$conn.open()
#Creates sql command
if ($conn.Open())
{
Write-Host "connection established..."
}
$cmd.connection = $conn
#$cmd.executenonquery()
$queryResult = $cmd.ExecuteReader()
$conn.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment