[Gambas-user] DataSource

Martin mbelmonte at belmotek.net
Mon Nov 23 09:38:29 CET 2020


Hi,

I don't usually use the db.form component but maybe you could use the 
"filter" property to restrict to a single record and then
Datasource.Filter = DB.Subst ("prenom = & 1", martin)
If you have a test project to take a look maybe I can think of something 
else.

Anyway this can help too


Public Sub Form_Open()

   Dim f As ResultField
   Dim res As Result

   res = db.Current.Exec("SELECT * FROM tutabla WHERE id='3'")

   If res Then
     If res.Fields.Exist("tucampo") Then
       Print res.Fields["tucampo"]
     Endif
   Endif

End

Martin

On 22/11/20 22:59, Fabien Bodard wrote:
> I need help..
>
> I want my datasource reach a given line given one field and not a line
> index... how can I achieve that quickly ... Actually I'm doing it by a
> Force and stupid way.
>
>
> Static Private reference As String
>
> Public Sub Run(Value As String)
>
>    reference = Value
>    FClientEdit.Showmodal
>
> End
>
> Public Sub Form_Open()
>
>    Dim i As Integer
>    Dim aGeo As String[]
>
> '----- HERE HOW TO FIND LINE :-/ --------------
>    DataSource1.MoveFirst
>    For i = 0 To DataSource1.Count - 1
>      If DataSource1["reference"] = reference Then Break
>      DataSource1.MoveNext
>    Next
> '-------------------------------------------
>
>    Me.Text = DataSource1["reference"] & " - " & DataSource1["nom"] & "
> " & DataSource1["prenom"]
>
>    If Not DataSource1!geo Then
>      MapView1.Enabled = False
>    Else
>      MapView1.Map.AddTile("OpenStreetMap",
> "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", Null).Copyright =
> "© OpenStreetMap " & ("contributors")
>      MapView1.Map.Zoom = 12
>      MapView1.Map.AddShape("clients")
>      aGeo = Split(DataSource1!geo, " ")
>      MapView1.Map.Center = MapPoint(aGeo[0], aGeo[1])
>      MapView1.Map["clients"].AddPoint(DataSource1!reference,
> MapPoint(aGeo[0], aGeo[1]))
>    Endif
>
> End
>
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201123/d11837af/attachment.htm>


More information about the User mailing list