Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

use odbc from powershell

$conn = new-object System.Data.Odbc.OdbcConnection
$conn.connectionstring = "DSN=DSNNAME" # Find "DSNNAME" (i.e. connection name) in ODBC Data Source Admin > User DSN
$sqlCommand="SELECT VERSION();"
$conn.open()

$cmd = New-object System.Data.Odbc.OdbcCommand($sqlCommand,$conn)
$dataset = New-Object System.Data.DataSet
(New-Object System.Data.Odbc.OdbcDataAdapter($cmd)).Fill($dataSet)
$conn.Close()

$dataSet
$dataSet.Tables
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #odbc #powershell
ADD COMMENT
Topic
Name
5+1 =