[Gambas-user] Using DataBrowser for a table which
John Rose
john.aaron.rose at ...626...
Wed Aug 22 20:07:22 CEST 2012
This gets ever more mysterious. The 'Out of Bounds' error has now gone.
However, I'm back to the original problem, namely (even with Benoit's
instructions):
I select a country of France. I click Centre Maintenance button. I click
(on the displayed FCentreMaintenance form) the New icon (within
DataBrowserCentre). I enter Paris (for Centre) and 1 (for Country Id,
though I don't think that I should have to as the Save action should
know about the Foreign Key from the centre table to the country table).
I click the Save icon (within DataBrowserCentre). The window does not
show the added Paris row. I then Exit the FCentreMaintenance form. I
return to the FCentreMaintenance form and it still does not show the
added Rome row. I check the centre table using SQLite Manager and the
Paris row is there but with country_id set null/blank. Screenshots
showing the above are in the attached file.
Now I have:
the Primary Key for the country table as country_id,
country_id for the Foreign Key (to the country table) in the centre
table.
DataBrowserCentre embedded in DataSourceCentre
which is embedded in DataSourceCountry,
DataSourceCountry.Filter as "country_id = " & CountryId,
DataSourceCentre.Filter as "country_id = " & CountryId),
(where CountryId is a variable containing the appropriate value).
Database table 'Creates' are:
Create Table country (country_id Integer Primary Key AutoIncrement,
country Text Not Null);
Create Table centre (_id Integer Primary Key AutoIncrement,
centre Text Not Null,
country_id Integer,
Foreign Key (country_id) References country
(country_id)
On Delete Cascade
On Update Cascade);
Code for starting the FCentreMaintenance form:
Public Sub ButtonCentreMaintenance_Click()
Dim hForm As FCentreMaintenance
Print "Country=", Country
Print "CountryId=", CountryId
hform = New FCentreMaintenance
hForm.TextBoxCountry.Text = Country
hForm.TextBoxCountryId.Text = CountryId
hForm.DataSourceCountry.Connection = MDatabase.DatabaseConnection
hForm.DataSourceCountry.Table = "country"
hForm.DataSourceCountry.Filter = "country_id = " & CountryId
Print "hForm.DataSourceCountry.Filter = ",
hForm.DataSourceCountry.Filter
hForm.DataSourceCountry.Update()
hForm.DataSourceCentre.Connection = MDatabase.DatabaseConnection
hForm.DataSourceCentre.Table = "centre"
hForm.DataSourceCentre.Filter = "country_id = " & CountryId
Print "hForm.DataSourceCentre.Filter = ",
hForm.DataSourceCentre.Filter
hForm.DataSourceCentre.Update()
hForm.DataBrowserCentre.Columns = ["centre", "country_id"]
hForm.DataBrowserCentre.Labels = ["Centre", "CountryId"]
hForm.DataBrowserCentre.Editable = True
hForm.DataBrowserCentre.Refresh
hForm.DataBrowserCentre.SetFocus()
Print "FCentreMaintenance form about to Show"
hForm.Show()
End#
Screenshot of the FCentreMaintenance form is th elast screenshot of the
attached file.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DataBrowser.tar.bz2
Type: application/x-bzip-compressed-tar
Size: 130661 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20120822/cf87c6b6/attachment.bin>
More information about the User
mailing list