Hi Team,
i am trying to connect postgres ODBC driver into SQL server data project to compare the Schema.
Power Shell script is:
ion Get-ODBC-Data{
param([string]$query=$(throw 'query is required.'))
$conn = New-Object System.Data.Odbc.OdbcConnection
$conn.ConnectionString = "Driver={PostgreSQL Unicode(x64)};Server=localhost;Port=5432;Database=nyc_data;Uid=postgres;Pwd=postgres;"
$conn.open()
$cmd = New-object System.Data.Odbc.OdbcCommand($query,$conn)
$ds = New-Object system.Data.DataSet
(New-Object system.Data.odbc.odbcDataAdapter($cmd)).fill($ds) | out-null
$conn.close()
$ds.Tables[0]
}
function Set-ODBC-Data{
param([string]$query=$(throw 'query is required.'))
$conn = New-Object System.Data.Odbc.OdbcConnection
$conn.ConnectionString= "Driver={PostgreSQL Unicode(x64)};Server=localhost;Port=5432;Database=nyc_data;Uid=postgres;Pwd=postgres;"
$cmd = new-object System.Data.Odbc.OdbcCommand($query,$conn)
$conn.open()
$cmd.ExecuteNonQuery()
$conn.close()
}
$query = "select * from ***"
$result = Get-ODBC-Data -query $query
set-odbc-data -query $query
in Power shell script it's successfully connected and same code moved to pre build event in sql server data base project.
getting the below error and please help me on this?
Severity Code Description Project File Line Suppression State
Error 03073: The command "function Get-ODBC-Data{ param([string]$query=) $conn = New-Object System.Data.Odbc.OdbcConnection $conn.ConnectionString = "Driver={PostgreSQL Unicode(x64)};Server=localhost;Port=5432;Database=nyc_data;Uid=postgres;Pwd=postgres;" $conn.open() $cmd = New-object System.Data.Odbc.OdbcCommand($query,$conn) $ds = New-Object system.Data.DataSet (New-Object system.Data.odbc.odbcDataAdapter($cmd)).fill($ds) | out-null $conn.close() $ds.Tables[0]}function Set-ODBC-Data{ param([string]$query=) $conn = New-Object System.Data.Odbc.OdbcConnection $conn.ConnectionString= "Driver={PostgreSQL Unicode(x64)};Server=localhost;Port=5432;Database=nyc_data;Uid=postgres;Pwd=postgres;" $cmd = new-object System.Data.Odbc.OdbcCommand($query,$conn) $conn.open() $cmd.ExecuteNonQuery() $conn.close()}$query = "select * from ***"$result = Get-ODBC-Data -query $queryset-odbc-data -query $query" exited with code 255. Database1 C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets 1330
is there any option to connect as a postgres sql as source in database connection in sql server data project?