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