Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Not sure which properties I need for this ODBC?

$
0
0

I've been searching for some documentation on what I need to make this work.  I have this script which was orginally intended for SQL.  I am replacing the SQL connection properties with ODBC properties.

My ODBC adapter is not working and I can't find reference to what properties are required. (Select, Connection, etc.)

I have .NET version 4.0.30319 installed.  I noticed different requirements for each version.

Thanks in advance for any guidance.

 

$AttachmentPath = "F:\SQLData.csv"

$SqlQuery = "

SELECT *

FROM table

"

$connectionString = "Driver={PostgreSQL Unicode(x64)};Server=xxxx;Port=xxxx;Database=xxxx;Uid=xxxx;Pwd=xxxx;"

$connection = New-Object System.Data.Odbc.OdbcConnection

$connection.ConnectionString = $connectionString

 

$command = New-Object System.Data.Odbc.OdbcDataAdapter

$command.SelectCommand = $SqlQuery

$command.Connection = $connection

 

$SqlAdapter = New-Object System.Data.Odbc.OdbcConnection

$SqlAdapter.SelectCommand = $command

$DataSet = New-Object System.Data.DataSet

$SqlAdapter.Fill($DataSet)

$connection.Close()

 

$DataSet.Tables[0] | Export-Csv $AttachmentPath


Viewing all articles
Browse latest Browse all 6937

Trending Articles