Skip to content

Instantly share code, notes, and snippets.

@ATLPhenx
Created April 28, 2016 23:32
Show Gist options
  • Save ATLPhenx/2fed75c6d7f46a8905fb3b5811a733bc to your computer and use it in GitHub Desktop.
Save ATLPhenx/2fed75c6d7f46a8905fb3b5811a733bc to your computer and use it in GitHub Desktop.
function selectPOSData ($Server, $Database, $SQLQuery, $Username, $Password) {
$Connection = New-Object System.Data.SQLClient.SQLConnection
$Connection.ConnectionString = "server='$Server';database='$Database';User ID= $Username; Password= $Password;"
$Connection.Open()
$Command = New-Object System.Data.SQLClient.SQLCommand
$Command.Connection = $Connection
$Command.CommandText = $SQLQuery
$Reader = $Command.ExecuteReader()
while ($Reader.Read())
{
$Reader.GetValue($1)
}
$Connection.Close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment