Connect to remote PostgreSql database using Powershell -
i'm trying connect remote postgresql database using powershell. first time using powershell i'm sorry if noob question. code:
$dbconnectionstring = "driver={postgresql unicode}:server=$myserver;port=$myport;database=$mydb;uid=$myuid;pwd=$mypass;" $dbconn = new-object system.data.odbc.odbcconnection; $dbconn.connectionstring = $dbconnectionstring; $dbconn.open(); $dbcmd = $dbconn.createcommand(); $dbcmd.commandtext = "select * mytable;"; $dbcmd.executereader(); $dbconn.close();
when run "exception calling "open" "0" argument(s): error [im002] [microsoft][odbc driver manager] data source name not found , no default driver specified". i've downloaded , installed pgsqlodbc driver i'm still getting error. have ideas how fix this? have searched internet , i'm not getting anywhere @ point.
thanks.
check if dsn exists in odbc data source. if not have create 1 going 'control panel', 'admin. tools', 'data sources (odbc)'. select 'add user dsn'- select postgresql driver, , fill in server , database details. test connection check ok!
Comments
Post a Comment