[Gambas-user] bug?

Benoît Minisini gambas at ...1...
Thu Nov 19 13:11:14 CET 2009


> Debian sid
> gb 2.17
> ==========
> 
> Hi,
> 
> I've got a module with public string & connection:
> 
> PUBLIC $DBConn AS NEW Connection
> PUBLIC MyHost AS String
> PUBLIC MyDB AS String
> PUBLIC MyUsr AS String
> PUBLIC MyPass AS String
> '---------------------------------
> PUBLIC FUNCTION DBConnect() AS Boolean
> PRINT MyDB & "." & MyHost & "." & MyUsr & ":" & MyPass
>   WITH $DBConn
>     .Type = "postgresql"
>     .Host = MyHost
>     .Name = MyDB
>     .Port = "5432"
>     .Login = MyUsr
>     .Password = MyPass
>   END WITH
>   TRY $DBConn.Open
>   IF ERROR THEN
>      Message.Error(("Can't connect to DB") & "\n\n" & Error.Text)
>     RETURN FALSE
>   ELSE
>     RETURN TRUE
>   ENDIF
> END
> 
> If I forget to fill MyHost & MyDB from the class that calls it, the
> function don't raise any error and returns TRUE (?)
> 
> How can that be?
> 
> JY
> 

Because there is a default host (localhost) and a default database. It works 
that way so that you can connect to the database server to get the list of 
existing databases.

Regards,

-- 
Benoît Minisini





More information about the User mailing list