Disappointed evaluator

Hi there,

Have spent a good few hours looking at Xojo now and initially very excited about the promise and pricing structure.
Worked through a couple of intro videos by Paul Levebre (I think) and all looked good. Then I started looking at the SQL Lite video eager to see how simple it would be to harness a database and easy it would be to manage tables and relationships, etc. I was so disappointed to discover that such an important aspect of rapid development was still in the stone-age in Xojo, i.e. hand-coded SQL and no grids just list boxes with clumsy properties management, etc. I appreciate that the die-hard programmers on this forum probably rejoice in this hands-on total control, but I and probably many others evaluating Xojo are used to better things from a wide range of development tool vendors.
I hope I am missing something here and that there are database features I have not discovered yet, or third-party offerings that simplify this important area of application development.
Please, can someone give me some good news here?

Thanks,

Paul

Exactly what features are you looking for? You say no grids, there is a Listbox control which takes a matter of minutes to code up to show a recordset from a database. Are you looking for data aware controls? List out some expected feature requirements and I and others will try and tell you how these are implemented.

Hi Mike, Some simple examples,

In the SQL Lite video, when running the application just connect to the database automatically, without having to use a drop down box to select the database connection every time (I imagine Paul was circumventing something here)
In database related window development, having previously specified (in project properties) the database connection for the application identify the table/tables required and then drag a single grid onto the window. Right click or similar on a grid identify the table and fields required. The grid and each table field should have a related property box. Rather than having to add them manually , by default there should be generated coded buttons to create a record, modify a record, delete a record, query mode only, save button for updated/created/deleted records and a cancel button to reset unwanted current grid record entries, etc.

Paul

Hi Markus,

I’m actually C of E :slight_smile:

Paul

What is BH?

Paul/Dermot,

I was exactly the same as you when i first started with Xojo. Great interface, loved the controls, and the overall way of doing things; until it came to the database bits. It had me stumped for a little while, but after going through some of the very good examples provided with the installed system and asking a few questions here on the very helpful forums, I soon got it going.

Yes, the hand coding can be a pain, and not what is totally expected; one thing I would say though is to take a look at containercontrols. I started with the view that I didnt want to bend and manipulate my data to fit the database controls that were offered, I wanted it the other way round. Xojo could produce a datagrid with drag and drop to accept tables; but it would be very generic and still need time spent tweaking and setting up the control and properties. It is something that has been asked about many times in the forums.

One thing I realised about the containercontrol is that I can use it to produce my own custom display of data, with all of the built in controls, buttons, add/edit/delete functionality, as well as all of the code necessary for opening the database and loading the data. This works since I can produce it to work around my data instead of the other way round. Then I can just drop it onto a window and all the functionality is in place and ready to go.

I suppose it depends what you want the end result to be and how you would like to get there; we all love the simplicity of drag and drop data-aware controls, but I think you have to be willing to put some work in as well. I’m no Xojo expert here, I defer to others if I get stuck, but try not to dismiss Xojo just because you dont initially see what other packages and environments have provided; chances are you can achieve what you want, but maybe in a slightly different way thats all.

:slight_smile:

Thanks Stephen,

I guess at the expense of inflated deployment costs I have been spoilt by being shielded from having to originate SQL and swathes of code in the past.
I’ll definitely look into your suggestions. Do you know if there are any videos that would be of use or specific document tutorials I should read?
Also, it would be interesting to know if there is a best practices document for sql and realbasic code re-use - i.e. standard routines or functions, called or included. You probably realise from the last bit that my coding prowess was at it’s best back in my COBOL days :slight_smile:

Thanks again,

Paul :slight_smile:

Bob Keeney has a series of training videos available on his website (www.bkeeney.com) which cover many of the key aspects of Xojo with working examples and he talks you through what he is doing and why during the videos. It is a commercial product but looking at the prices, very good value I reckon. Bob is also an active member of the forums here.

Code re-use, for me, is down to how I want to use it, where, and how many times. Xojo ‘Methods’ can accept multiple parameters and be set to return one or more values too. So you could pass say the DB name and table name as 2 parameters and then return an integer value that indicates whether everything has succeeded. Multiple return values are also possible but is a little more involved. I have always stuck to using a single return value in the form of an integer; I always return 0 for success, and then other positive values to indicate something has not worked as expected. Coding for databases also has its own set of errorcodes which could be passed as a return value instead.

I have not seen a best practise document as such, but there are several users here on the forums who will usually tell you the best way to do something if you are not sure, and give a reason as to why.

From what I have picked up here on the forums, and the examples I have looked at, here is what I have done, which is attached to the open event of a login window to a program, that checks user credentials:

  Dim UserDB As New SQLiteDatabase
  
  UserDB.DatabaseFile = GetFolderItem("User.sqlite")
  
  If Not UserDB.Connect Then
        Msgbox("Unable to open database")
  Else
     Dim UserNames As RecordSet
    UserNames = UserDB.SQLSelect("SELECT UserName FROM Users ORDER BY UserName")
    
    If UserDB.Error Then
      MsgBox("Database error : " + UserDB.ErrorMessage)
      Exit
    End If
    
    LoginControl.pmUsername.DeleteAllRows
    
    If UserNames <> Nil Then ' Populate the 'pmUserName' popupmenu with User Names
      While Not UserNames.EOF
        LoginControl.pmUsername.AddRow(UserNames.IdxField(1).StringValue)
        UserNames.MoveNext
      Wend
    End If
    UserNames.Close
    
    Dim UserRoles As RecordSet
    UserRoles = UserDB.SQLSelect("SELECT RoleDescription FROM Roles ORDER BY RoleDescription")
    
    If UserDB.Error Then
      MsgBox("Database error : " + UserDB.ErrorMessage)
      Exit
    End If
    
    LoginControl.pmRole.DeleteAllRows
    
    If UserRoles <> Nil Then ' Populate the 'pmRole' popupmenu with User Roles
      While Not UserRoles.EOF
        LoginControl.pmRole.AddRow(UserRoles.IdxField(1).StringValue)
        UserRoles.MoveNext
      Wend
    End If
    UserRoles.Close
    
  End If
  

In this code, I query the same table twice to load a list of User Names into a popupmenu, then load a list of User Roles into a second popupmenu.

There are several things in this code that I have picked up as I’m going along:

After setting the name of the database, the rest of the code sits in an ‘If… Then… Else’ where I first check to see if the database has opened successfully. If not, it shows me a message box warning me and then exits since there is no point trying to run any more of the code.

Once opened, I create a recordset to hold the results of the SQL query and then issue the SQL itself.

Immediately after SQL statement is issued, I then check for errors again. This is good practise generally and tells me straight away if I have something wrong with my SQL statements.

Assuming no errors, I clear the popupmenu control of any existing data and load the contents of the recordset into them accordingly.

The process is then repeated, but using the same database I have already opened since both tables reside there.

Once I get to the end of the data, I close the recordset.

I am only querying a single column of each table in this case, so the code is quite simple, but I use these same principles whenever I use a database.

You could also add this same code to a containercontrol, and even add some pre-defined SQL statements in your program; these pre-defined SQL statements are useful as you can effectively write them once, test them, and then store them, which means less errors and less coding.

Ive even built a containercontrol which adds a series of search boxes directly beneath a listbox; it then queries the selected database for whatever is entered in the boxes. I think I called it ‘DBsearch’ or something similar and then just add it on screen whenever i use a listbox. 90% of the code including the actual search routine is already written and tested and it makes extensive use of pre-defined SQL statements. I simply change a few parameters each time I use it. Its about as close to a drag and drop control as I want and works perfectly.

Thanks Stephen.

Very interesting. So, essentially, it’s a case of thinking through the issues and how to approach them in different ways, but ways that can be re-used and parameterised to suit future similar requirements.
I will study the code and see if I can produce something similar.
I found a few videos that look as though they will help me and I will check out the Bob Keeney site.

Thanks again,

Paul

Hi Paul,

In addition to Bob’s good resource, there has also been a book published on SQLite for Xojo at SQLite for Xojo at RBLibrary .

Happy to help,

Eugene

I think so yes. When I coded my first few databases I did it very specifically, but paying little attention to the broader approaches that were possible; thats where I realised I was retyping endless lines of code when in fact I could be doing it in a much smarter way.

I dont know the limit for how many parameters you can pass to a Method, but I’ve seen some methods that use a lot. My biggest to date I think is 13 or 14 parameters and it worked exactly as expected, though in the end I split it into two more manageable methods and simply passed the return values of the first as parameters to the second.

[quote=152485:@Eugene Dakin]Hi Paul,

In addition to Bob’s good resource, there has also been a book published on SQLite for Xojo at SQLite for Xojo at RBLibrary .

Happy to help,

Eugene[/quote]

This is a good point and something I forgot to mention actually. There are a number of developers out there who have produced some very good reusable components and such, that you can import and use in your programs.

A good example of this is the Omega Bundle, which is currently on offer and has a very good selection. You can also go to the individual developers’ sites to see what else they have to offer.

Hi Stephen and Eugene,

Thanks for the extra info. I’ve got a lot more background detail now, so will spend time developing something based around the advice you have offered.

Paul :slight_smile:

It is totally off-topic, Eugene Dakin but nice to see you here, I love your I wish I could series. Well worth the price.

Thanks from the Netherlands!

[quote=152468:@Dermot Doherty]Hi there,

Have spent a good few hours looking at Xojo now and initially very excited about the promise and pricing structure.
Worked through a couple of intro videos by Paul Levebre (I think) and all looked good. Then I started looking at the SQL Lite video eager to see how simple it would be to harness a database and easy it would be to manage tables and relationships, etc. I was so disappointed to discover that such an important aspect of rapid development was still in the stone-age in Xojo, i.e. hand-coded SQL and no grids just list boxes with clumsy properties management, etc. I appreciate that the die-hard programmers on this forum probably rejoice in this hands-on total control, but I and probably many others evaluating Xojo are used to better things from a wide range of development tool vendors.
I hope I am missing something here and that there are database features I have not discovered yet, or third-party offerings that simplify this important area of application development.
Please, can someone give me some good news here?

Thanks,

Paul[/quote]
Hi Dermot,

Yes, Xojo needs better database connectivity, there’s no doubt about it. And it’s on our list once we get through a few other higher priority items first.

[quote=153804:@Geoff Perlman]Hi Dermot,

Yes, Xojo needs better database connectivity, there’s no doubt about it. And it’s on our list once we get through a few other higher priority items first.[/quote]

Geoff,

Are you talking about supporting more databases, or improving what we have already ?

Improving the way you create applications that connect to databases. @Dermot Doherty is absolutely right that you should not have to write so much code to get data in and out of a database. We will eventually address that.

And eliminating the tedium of database coding we have ActiveRecord which a lot of people seem to like. It eliminates most of the SQL coding, lets you have auto complete of table and field names, actually checks the data type’s against field types and so on. It is not perfect but it’s help us in a lot of our consulting projects. Plus it makes the whole db thing more object oriented. http://www.bkeeney.com/rbinto/activerecord/ It’s free for use but the utility to make the Xojo classes is not.

we use nothing but ActiveRecord now for all our database needs. We are lucky that every type of database we need to talk to is supported by ActiveRecord.

@Bob Keeney thanks for ActiveRecord.

@Geoff Perlman you might want to take a look at how Iron Speed Designer (RAD .NET code generator) works with databases. On the positive side it creates all the CRUD (Create/Update/Delete) methods and display panels for all selected database tables. On the negative side the generated apps are quite bloated. Striking a balance between generated code to save time and generating too much code creating bloat will be challenging, I am sure. Most of my development is in-house for my employer, and much requires SQL Server database connectivity, so I admit I am a bit concerned about the learning curve, but despite that I am throwing my hat into the Xojo ring tonight by buying the Pro license. I am very excited to join the community. Thanks for a great product.

@Bob Keeney will be downloading ActiveRecord and purchasing ARGen ASAP.