Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ATLPhenx/c5a22cc73494caf35e35451eac550f8e to your computer and use it in GitHub Desktop.
Save ATLPhenx/c5a22cc73494caf35e35451eac550f8e to your computer and use it in GitHub Desktop.
function selectPOSData ($Server, $Database, $query, $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 = $query
#Set the SqlDataAdapter's SelectCommand.
# Fill the DataSet.
$ds=New-Object system.Data.DataSet
$da=New-Object system.Data.SqlClient.SqlDataAdapter($Command)
$da.fill($ds) | Out-Null
$Connection.Close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment