[Gambas-user] Looking up data from a second table

bkv at mailbox.org bkv at mailbox.org
Mon Feb 19 23:19:10 CET 2018


Danke Chrisof and Lee

I tried to enter the sql select statement into the Table property of the Datasource as suggested. Gambas will let me write text into this property only if I let the Connection property be blank. In that case  calling the MoveFirst method fails. Something is not right.

I also created the view in the sqlite3 console, but the view does not show up in Gambas, so I wasn't able to use it.

Please remember that the main purpose of this form is to maintain the patron record. I need the field from krutt only as additional information displayed.


-Bjørn


> On February 19, 2018 at 10:37 PM Christof Thalhofer wrote:
> 
> 
>     Am 19.02.2018 um 21:17 schrieb bkv at mailbox.org mailto:bkv at mailbox.org :
> 
>         > > I have a form with a Datasource and the datasource's Table property is
> >         set to a table called /patron./ I have some fields from /patron/ in my
> >         form and I view and update them.
> > 
> >         Now, patron also has a foreign key to a table called /krutt,/ named
> >         /krutt_id./ I need to get one field out of /krutt/ and display it on my
> >         form (read only).
> > 
> >         I can do this with a db.select using the /krutt_id/ from /patron/ as key
> >         to table /krutt/ when I put the field /krutt_id/ from /patron/ on my
> >         form and make it visible. But I don't want to display the field
> >         /krutt_id /on my form.
> > 
> >         Is there any way I can get the value of /krutt_id/ without putting it on
> >         the form? I have looked at the Datasource object with no result.
> > 
> >         Or is there a complete different solution?
> > 
> >     >     Normally such is done with a sql query like:
> 
>     "select patron_a, patron_b, thisisfromkrutt from patron, krutt where
>     patron.krutt_id = krutt.id;"
> 
>     if for every patron is a tuple in krutt.
> 
>     Or:
> 
>     "select patron_a, patron_b, thisisfromkrutt from patron left join krutt
>     on patron.krutt_id = krutt.id;"
> 
>     if not every parton has a corresponding tuple in krutt.
> 
>     You can store this sql string into DataSource.Table instead of tablename.
> 
>     You also could store this sql string in your database as a view and use
>     the view's name as tablename.
> 
>     Alles Gute
> 
>     Christof Thalhofer
> 
>     --
>     Dies ist keine Signatur
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20180219/a00b77a2/attachment.html>


More information about the User mailing list