realbasic-nug
[Top] [All Lists]

PostgreSQLDatabase Connections

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: PostgreSQLDatabase Connections
From: Robert Lawrence <robl at no-no-badpuppy dot com>
Date: Wed, 30 Apr 2008 09:56:38 -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
In RB 2008 R1 (not sure about earlier releases), I am seeing some  
oddness in behavior.  It seems if PostgreSQLDatabase.Connect will  
return true as long as Host, port, username, and password is correct.   
It doesn't seem to take into consideration if the DatabaseName exists  
on the server or if the user has permissions to that database.

I have a windows with edit fields for the basic PostgreSQL Database  
connection details and a button to test that the connections are  
correct.  The Action() for the pushbutton contains the following:

   Dim db as PostgreSQLDatabase
   db = New PostgreSQLDatabase
   db.host = fldHost.Text
   db.port = Val(fldPort.Text)
   db.DatabaseName = fldDatabase.Text
   db.Username = fldUser.Text
   db.Password = fldPassword.Text

   if db.connect then
     MsgBox "Congratulations!  Connection with database verified."
     db.close
   else
     MsgBox "Uh oh!  Something is wrong.  Check the server details and  
firewall settings."
   end if


Using the above example, I can enter valid information for Host, Port,  
Username, and Password.  Then enter random string for Database name  
and it will pop up with a MsgBox stating that the connection is working.

Enter wrong data for any host, port, user, or password and I will get  
the "Something is wrong" MsgBox.

How do I verify that all of the details, including the DatbaseName are  
valid?  As the app I am working can working with various databases on  
a PostgreSQL server, it has no expectation of any particular tables  
existing, so I can't verify by testing for the existence of specific  
database contents.  (I may need to connect to a new database without  
any tables created yet).

Does anyone have a suggestion on how to verify if the connection to a  
specific database is valid?

Thanks!

Robert
_______________________________________________
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>