Is using the DataControl for data binding still a bad idea?

So in my quest to get a working database with my app, I came across the tutorial at GettingStarted:SQLite Basics again (as I did in 2019) in which the DataControl object is used to bind the Xojo Interface to the Database tables. Is it still a bad idea to go this route instead of coding everything? I am able to populate all the text fields in my app now with the database data, but the information about how to create new records and insert them into the Database still don’t work which was also a problem when I tried this in 2019 with the old Xojo version.

And it worked ?

Did you tried the project ?

I worked through it this morning with my current project. The retrieving of text field data works, but adding a new record to the database does not.

This code (as showed in the tutorial) does not create a new record in the database:

DataControl1.NewRecord
DataControl1.Insert
DataControl1.RunQuery
DataControl1.MoveLast

btnDeleteStory.Enabled = true

btnInsertRecord.enabled = true
btnUpdate.Enabled = false
btnDeleteStory.Enabled = false

StoryPK.text = “”

A simple search in the documentation leads me to:

https://documentation.xojo.com/resources/deprecations.html#resources-deprecations-2018-release-4

That says it all, although I had to look it up :slight_smile:
recommend against using something on the grounds that it is obsolete

So I better not use it, pity, it seems to be a very easy to make the bindings. I wonder why this isn’t a more popular method or at least updated. For Xojo beginners Database binding can be very complicated, this would be a great way to get simple projects going.

That was, one day in the past, until it started to works “wonky”… and be deprecated.

it’s quite easy - and a good exercice - to make one yourself, using a containercontrol and a few buttons inside. then it will never be deprecated !

1 Like

I am about to enter my 40th year in software development (and my 40th day of Xojo development, lol) and have yet to meet a data-binding scheme that I liked. Something weird always starts happening at some point and I’m fighting this black box. I have long preferred to roll my own. I can precisely optimize the underlying SQL and whatever goes wrong is my own damn fault, and THAT I can work with.

Another problem with data binding is that it tends to become over-engineered or at least over-abstracted to handle edge cases rather than typical cases.

It does look like some form of data binding framework is in the roadmap for Xojo, but I’m not waiting around for it. I think the idea of such things is make it easy for RAD: drop a grid, drag a table to it, call methods on the control to update or add, and done. In theory. Never seems to quite work out that way.

3 Likes

I hope the new upcoming Xojo/Sqlite Udemy course will make things clearer. On his YouTube channel Learn with Byron, he has a very easy and relaxed way of explaining programming problems which helped me a lot in understanding Xojo. He is talking about the upcoming course in this video: