I am new to Xojo, just imported one of my two VB programs that need to be updated.
I can see my data on my mysql database server, and it displays in the forms that I have created. However, it does not save the changes that I make in the forms.
In the data app I have selected the database, and the table. In the sql window I have “SELECT * FROM xxxxxx” (xxxxx would be the table name, depending on what form is open at the moment).
Am I missing a control setting, or what needs to be added to have the data control update the field?
I hope not missunderstanding you. but here is an example how you update Mysql data from simple textfield.
Dim rs as RecordSet
Dim Db as mySQLCommunityServer
// Connect to MySQLServer
If Db.Connect then //If the database connected:
rs = Db.SQLSelect("SELECT * FROM TableName WHERE primaryKey ='" +TxtFieldID.Text + "'")
if(rs.RecordCount <> 0) then
TxtFieldID.Text = rs.IdxField(1).StringValue
if TxtFieldEpost.text="" then
if TxtFieldEName.text="" then
rs.IdxField(3).StringValue =ConvertEncoding(Lowercase(TxtFieldName.text), Encodings.ISOLatin1)
MsgBox("User Not found")
if (Db.error) then
msgBox("FAILED!!! " + Db.errorMessage)
Monzer, this is very interesting. I am also finding it impossible toget DataControl to perform any task other than simple browsing of tables.
Are you saying that the DataControl methods cannot be used to Edit / Update / Insert records??
Use of DataControl is discouraged. It doesn’t really work. At least, not very well. It is much better to use RecordSet directly or use Prepared Statements. It’s a little more work, but a lot more flexible. And you have control over the process, which is a lot more than you can say with DataControl.
Xojo should just remove the DataControl.
There is very little reason to use DataControl except for the simplest of apps.
However, it does work. Are you calling DataControl.Update or DataControl.Insert to change or add new data as appropriate?
User Guide Book 3: Framework, Chapter 4: Databases, Section 2: Simple Database Usage has some more details on DataControl.
Paul is right here (and certainly most if not all the time).
I implemented my own * and when I was no more in a hurry, I took time to make a check in the Language Reference and found DataControl to realize it the way Paul wrote above.
- I had in mind a souvenir of a DataControl from FileMaker (I think), so I implemented something like that but without graphics (no time to search or draw them).