realbasic-nug
[Top] [All Lists]

Re: PostgreSQLDatabase Connections

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: PostgreSQLDatabase Connections
From: Norman Palardy <npalardy at great-white-software dot com>
Date: Wed, 30 Apr 2008 09:03:20 -0600
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>
On 30-Apr-08, at 8:56 AM, Robert Lawrence wrote:

> 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

I'd reported this bug with the plugin some time ago <http:// 
realsoftware.com/feedback/viewreport.php?reportid=yuhhlkwv>
But it was marked not reproducible

Try adding this code to yours where you show the congrats message to  
see what database you ARE connecting to

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>