How to use PowerShell with QODBC
Download Sample
Sample Code for using QODBC DSN:
$connectstring = "DSN=QuickBooks Data;"
$sql = "Select TOP 10 Name from Customer"
$conn = New-Object System.Data.Odbc.OdbcConnection($connectstring)
$conn.open()
$cmd = New-Object system.Data.Odbc.OdbcCommand($sql,$conn)
$da = New-Object system.Data.Odbc.OdbcDataAdapter($cmd)
$dt = New-Object system.Data. data table
$null = $da.fill($dt)
$conn.close()
$dt
Script execution & Result:
Open Windows PowerShell (x86) from the start menu:
Navigate to your PowerShell script folder:
Run your PowerShell script:
Result:
Sample Code for using QRemote DSN:
$connectstring = "DSN=QuickBooks Data QRemote;"
$sql = "Select TOP 10 Name from Customer"
$conn = New-Object System.Data.Odbc.OdbcConnection($connectstring)
$conn.open()
$cmd = New-Object system.Data.Odbc.OdbcCommand($sql,$conn)
$da = New-Object system.Data.Odbc.OdbcDataAdapter($cmd)
$dt = New-Object system.Data. data table
$null = $da.fill($dt)
$conn.close()
$dt
Please refer: To how to configure QRemote.
Please Note: If you have a 64-bit application, you must use QRemote 64-bit DSN "QuickBooks Data 64-bit QRemote."
Also, Refer:
QODBC Reports Architecture Mismatch Problem When connecting
|