realbasic-nug
[Top] [All Lists]

Re: PostgreSQLDatabase Connections

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: PostgreSQLDatabase Connections
From: Robert Lawrence <robl at no-no-badpuppy dot com>
Date: Wed, 30 Apr 2008 10:22:37 -0500
Authentication-results: mx.google.com; spf=pass (google.com: domain of realbasic-nug-bounces at lists dot realsoftware dot com designates 66.116.103.65 as permitted sender) smtp dot mail=realbasic-nug-bounces at lists dot realsoftware dot com
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <8259D3C7-7012-44FF-8D71-FC9FE80003D9 at no-no-badpuppy dot com> <082046DE-73EF-4340-8A3F-361B9B037AA9 at great-white-software dot com>
Norman:

Thanks for the tip.    It brings to light another oddity.  Playing  
with this revised code (based on your idea), it looks like its  
connecting to the database that has the same name as the username.   
It's ignoring the DatabaseName completely.

   Dim db as PostgreSQLDatabase
   Dim rs as RecordSet

   db = New PostgreSQLDatabase
   db.host = fldHost.Text
   db.port = Val(fldPort.Text)
   ' db.DatabaseName = fldDatabase.Text
   db.DatabaseName = "postgres"

   db.Username = fldUser.Text
   db.Password = fldPassword.Text

   if db.connect then
     MsgBox "Congratulations!  Communications with database verified."

     rs = db.SQLSelect("select current_database()")
     if  rs.RecordCount = 1 then
       msgbox "Connected to " + rs.IdxField(1).StringValue
     end if

     db.close
   else
     MsgBox "Uh oh!  Something is wrong.  Check the server details and  
firewall settings."
   end if


Notice that I hardcoded .DatabaseName to "postgres".  I use my  
"rbtest" username when I run this code.  It tells me it connected to  
"rbtest" database.    I changed DatabaseName to "rbtest" and tried to  
login as postgres user.  It connected to the postgres database.

Something is definitely weird here.

Regards,
Robert


On Apr 30, 2008, at 10:03 AM, Norman Palardy wrote:

> dim rs as RecordSet = db.SQLSelect("select current_database()")
>
> if not rs is nil then
>        msgbox "Connecte to " + rs.IdxField(1).StringValue
> end if

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>