Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Uploaded via PowerShell
$dbName="SAMPLE"
$server="not.my.localhost"
#Define connection string for the database
$cn = new-object system.data.OleDb.OleDbConnection("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
$cn.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment