Skip to content

Instantly share code, notes, and snippets.

Created November 20, 2020 16:12
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Uploaded via PowerShell
#Define connection string for the database
$cn = new-object"server=$($server);Provider=IBMDADB2;DSN=$($dbName);trusted_connection=true;");
#Define data set for first query
$ds = new-object "System.Data.DataSet" "ds"
#Define query to run
$q = "select * from hello_world"
# Define data object given the specific query and connection string
$da = new-object "System.Data.OleDb.OleDbDataAdapter" ($q, $cn)
# Fill the data set - essentially run the query.
$da.Fill($ds) | Out-Null
# Print the result
foreach ($Rows in $ds.Tables[0].Rows)
$Rows | Format-Table
# Close the Connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment