Jump to content
Sign in to follow this  

Connecting to PostgreSQL

Recommended Posts


Hi Guys,

I have searched your forum for my answer and found a couple of helpful topics but none actually answers my problem.

I have a PostgreSQL database on another computer and I am trying to access it across the network. I have setup the following in AutoIT:


Local $oRS

Local $oConn

$line = 2

$GameNumber = ... number of current game ...

$PlayerID = ... name of player ...

; Open Access DB Connection

$oConn = ObjCreate("ADODB.Connection")

$oRS = ObjCreate("ADODB.Recordset")

;$oConn.Open ("Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\Poker\ptrack.mdb")

;$oConn.Open ("DRIVER={PostgreSQL};SERVER=IP address of server;DATABASE=PokerTracker;USER=postgres;PASSWORD=password;PORT=5432;")

$oConn.Open ("ODBC;DRIVER={PostgreSQL};SERVER=IP address of server;DATABASE=PokerTracker;Uid=postgres;Pwd=password;PORT=5432;") ; error appears to be on this line!!!

;Getting Players for current session - Includes VPIP

$oRS.Open ("SELECT game.table_name, game_players.player_id, (SELECT players.screen_name from players where game_players.player_id = players.player_id) AS screen_name, game_players.seat_number, game_players.session_id, (SELECT vol_saw_flop/total_hands AS VPIP FROM session WHERE game_players.session_id=session.session_id AND session.player_id=game_players.player_id) AS VPIP FROM game, game_players WHERE (((game.game_number)=" & $GameNumber & ") AND ((game_players.game_id)=[game].[game_id]))", $oConn, 1, 3)


For $iIndex = 1 To $oRS.RecordCount

;If $oRS.Fields ("ScreenName").value = $PlayerID Then

$TableName = $oRS.Fields ("table_name").value

$PlayersID = $oRS.Fields ("player_id").value

$ScreenName = $oRS.Fields ("screen_name").value

$SeatNumber = $oRS.Fields ("seat_number").value

$SessionID = $oRS.Fields ("session_id").value

$VPIP = Round($oRS.Fields ("VPIP").value * 100, 0) & "%"




MsgBox(1, "", "Table Name = " & $TableName & " Players ID = " & $PLayersID & " Screen Name = " & $ScreenName & " SeatNumber = " & $SeatNumber & " Session ID = " & $SessionID & " VPIP = "& $VPIP)


$oConn = 0


I had this working perfectly with Microsoft Access on the local machine but the database got too large and queries took too long. I converted the database to Postgres and it all works fine on the remote computer. The problem is I am trying to convert my AutoIT script to support the PostgreSQL. I have installed the ODBC driver for PostgreSQL on the local computer and had taken the format of the ODBC connection from a sample script incorporating it in to my Access Script format.

The popup msgbox error I am getting is: The requested action with this object has failed.

My question to you guys is have I gone about writing the script above correctly? Or can you suggest some chnages that may make it work?

I would very much appreciate your help...

Have a great weekend guys...



Share this post

Link to post
Share on other sites

does it say which line it is breaking on?

Share this post

Link to post
Share on other sites


Yes, the error appears on this line... the establishment of the ODBC connection.

$oConn.Open ("ODBC;DRIVER={PostgreSQL};SERVER=IP address of server;DATABASE=PokerTracker;Uid=postgres;Pwd=password;PORT=5432;")



Share this post

Link to post
Share on other sites

Please check out :

Learning is Lifelong!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.