On 30-Apr-08, at 9:22 AM, Robert Lawrence wrote:
> 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.
>
That's what my testing seemed to suggest as well
Running pgsql from my laptop to log in to a remote machine on my
network I get the following
macbookpro:~ npalardy$
macbookpro:~ npalardy$ /usr/local/pgsql/bin/psql -h 10.0.1.201 -U
npalardy -d test
Welcome to psql 8.2.4 (server 8.2.3), the PostgreSQL interactive
terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
test=> select current_database() ;
current_database
------------------
test
(1 row)
test=>
Using code much like yours
dim dbConnection as PostgreSQLDatabase
dim rs as RecordSet
dbConnection = new PostgreSQLDatabase
dbConnection.DatabaseName = "test"
dbConnection.Host = "10.0.1.201"
dbConnection.Port = 5432
dbConnection.UserName = "npalardy"
dbConnection.Password = ""
// make the connection to the database with the supplied paramaters
if dbConnection.connect = false then
msgbox "not connected " + dbConnection.ErrorMessage
return
end if
rs = dbConnection.SQLSelect("select current_database()")
if not(rs is nil) then
msgbox rs.IdxField(1).StringValue
end if
when I run this I get my NOT CONNECTED dialogue saying "database
"npalardy" does not exist
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|