[Gambas-user] Help DataSource, DataBrowse

Benoît Minisini gambas at ...1...
Sun Sep 6 14:21:23 CEST 2009


> Hi ,
> Please an help....I am practising with DataSorce using into my project the
> same form and class of the "database" example: in particular Ftest.class
> and Ftest.form.
>
> In my project I get the error:
>
>      Null Object DataSource.MoveFirst.173
>
> I guess that DataSource can not find my Connection to the database ...
>
> How can I tell to DataSource which is the Connection to use ?
> Is there a property of DataSource to set ?
>
> I make the connection in Mglobal.module with the following code:
> -----
> PUBLIC FUNCTION conn(dbtype AS String, host AS String, lgn AS String, pass
> AS String) AS Boolean
>
>   TRY $hConn.close
>   $hConn.Type = dbtype         '  "postgresql"
>   $hConn.Host = host
>   $hConn.Login = lgn
>   $hConn.Password = pass
>   $hConn.Open
>   RETURN TRUE
> CATCH
>   Message.error("conn", Error.Where & "\n" & Error.text)
>   RETURN FALSE
> END
> -------
> Where
> PUBLIC $hConn AS NEW Connection
> .....
>
> Many thanks
>
> Pino

You must open your connection before showing the form having the DataSource.

And in Gambas 3, you can specify explicitely a DataSource Connection object.

Regards,

-- 
Benoît




More information about the User mailing list