[Gambas-user] DataSource
Martin
mbelmonte at belmotek.net
Mon Nov 23 11:53:49 CET 2020
The answer is .Create
In this example, I use a temporary control to edit the data and then
delete the control, you could hide it instead of deleting it.
If you already have controls on your form, simply use .Create
Sorry but I couldn't find a way to do it without a data control.
Public Sub Form_Open()
Dim tb As Table
Dim fd As Field
Dim dt As DataControl
DataSource1.Connection.Open
DataSource1.Table = "clients"
DataSource1.Filter = db.Subst("cname = &1", "martin")
DataSource1.MoveFirst
dt = New DataControl(DataSource1) As "dat"
With dt
.Name = "temportal"
.Field = "cphone"
.Value = Format(Now(), "hhnnss.u")
End With
dt.Refresh
End
Public Sub Button1_Click()
Dim tdat As Control
DataSource1.Create
For Each tdat In DataSource1.Children
If tdat.Name = "temportal" Then
tdat.Delete
Endif
Next
Martin
On 23/11/20 11:08, Fabien Bodard wrote:
> My question is just about the ability to edit data if I use a filter
> on the datasource.
>
> Le lun. 23 nov. 2020 à 09:39, Martin <mbelmonte at belmotek.net
> <mailto:mbelmonte at belmotek.net>> a écrit :
>
> 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" <http://%7Bs%7D.tile.openstreetmap.org/%7Bz%7D/%7Bx%7D/%7By%7D.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 <http://gambaswiki.org/wiki/doc/netiquette> ]----
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette
> <http://gambaswiki.org/wiki/doc/netiquette> ]----
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201123/2deb91be/attachment-0001.htm>
More information about the User
mailing list