How to make a database application - step by step example

Please tell me where can I find a step by step example of how to make a database application.

There are some basic but very good tutorials on the Rea lSoftware Youtube channel.

RealSoftwareVideo

Very poor database example on Youtube. No database detailed documentation.

You may need to be a little more specific. Which type of database REALSQLdatabase, SQL, MySQL, SQLite, AccessDB etc.

MySQL

I have a Real Studio series for subscribers at http://www.bkeeney.com/XojoTraining/xojotraining.cgi. It’s an older Real Studio example but the basics are the same. I think it’s about 10 hours long and we go from start to finish on a journal (diary) application. I also have a couple of addendum videos that convert it to use MySQL and how to use ActiveRecord.

There is a MySQL video tut on the Real Software Channel that demonstrates creating, connecting to and executing queries.

Also look at the Xojo Language references and tutorials.

MySQL TuT

The old forum from Realsoftware ( http://forums.realsoftware.com) you might find some examples as well.

If it’s first time you have to familiarize your self with SQL databases. I would suggest you start with the REALSQLdatabase/SQLite , then you can do all local and don’t need to configure a MySQL server. And later you can move on to MySQL. Not much different between REALSQLdatabase and Mysql in Xojo/Realbasic coding.

I know MySQL server. I don’t know how to make database applications with Xojo and documentation is …

Where is Xojo detailed making database application? Nowhere.
Really Xojo is good for database applications? Or may I look elsewhere?

See DB tutorial at xojodevspot.com

Too much coding!
Seems to be complicated.

1 Like

That’s the way it is. Xojo is not FileMaker.

1 Like

The “Build My App For Me” button can be found in Preferences under the “Wishful Thinking” tab.

Xojo is a tool not a panacea.

Dig in. You may find it’s not so bad.

1 Like

Aurel,

I can give you some short examples here; how to create and read all content from a MySQL database.

Hope this can help you a little bit. Below code is using a listbox with 3 columns

Create Database

[code] Listbox1.DeleteAllRows
Listbox1.AddRow “Create Database”

Dim db As New MySQLCommunityServer
Dim rs As RecordSet

db.host = “HostName_Of_Database_Server” // If your application is running on same Mysql Server Set db.host = “localhost”
db.port = 3306
db.DatabaseName = “rstest”
db.UserName = “myname”
db.Password = “mypassword”

If Not db.Connect Then
Msgbox “Could not connect to database”
Else
db.SQLExecute(“CREATE table Items ( id INT NOT NULL AUTO_INCREMENT, name TEXT, number INTEGER, PRIMARY KEY(id) )”)

if db.Error Then
  MsgBox("DB Error: " + db.ErrorMessage)
Else
  
  db.SQLExecute("INSERT INTO Items(name, number) VALUES ( 'Car', 20)")
  db.SQLExecute("INSERT INTO Items(name, number) VALUES ( 'House', 21)")
  db.SQLExecute("INSERT INTO Items(name, number) VALUES ( 'Notebook', 22)")
  db.SQLExecute("INSERT INTO Items(name, number) VALUES ( 'Realsoftware', 23)")
  db.SQLExecute("INSERT INTO Items(name, number) VALUES ( 'Realsoftware', 24)")
  db.SQLExecute("INSERT INTO Items(name, number) VALUES ( 'Realsoftware', 25)")
  db.SQLExecute( "COMMIT" )
End If

rs = db.SQLSelect("SELECT * FROM Items")

If rs <> Nil Then
  While Not rs.EOF
    Listbox1.AddRow ""
    ListBox1.Cell(Listbox1.LastIndex,0) =  rs.Field("id").StringValue 
    ListBox1.Cell(Listbox1.LastIndex,1) =  rs.Field("name").StringValue
    ListBox1.Cell(Listbox1.LastIndex,2) =  rs.Field("number").StringValue
    rs.MoveNext
  Wend
  
Else
  If db.Error Then MsgBox(db.ErrorMessage)
End If
db.close
rs.Close

End If
[/code]

Read all content from Database

[code] Dim db as New MySQLCommunityServer
Dim rs As RecordSet

db.host = “HostName_Of_Database_Server” // If your application is running on same Mysql Server Set db.host = “localhost”
db.port = 3306
db.DatabaseName = “rstest”
db.UserName = “myname”
db.Password = “mypassword”

If Not db.Connect Then
Msgbox “Could not connect to database”
Else
rs = db.SQLSelect(“SELECT * FROM Items”)

If rs <> Nil Then
  rs.MoveFirst
  Listbox1.AddRow "Read Recordset"
  While Not rs.EOF
    Listbox1.AddRow ""
    ListBox1.Cell(Listbox1.LastIndex,0) =  rs.Field("id").StringValue
    ListBox1.Cell(Listbox1.LastIndex,1) =  rs.Field("name").StringValue
    ListBox1.Cell(Listbox1.LastIndex,2) =  rs.Field("number").StringValue
    rs.MoveNext
  Wend
Else
  If db.Error Then MsgBox(db.ErrorMessage)
End If
db.Close
rs.Close

End If[/code]

Thanks for the encouragement, Peter.

[quote=13640:@Aurel Vlase]Where is Xojo detailed making database application? Nowhere.
Really Xojo is good for database applications? Or may I look elsewhere?[/quote]
Xojo is commonly used for creating database applications, but you’ll have to put in a bit of effort on your part to learn how. It won’t do everything for you.

Connecting to MySQL works primarily the same as connecting to other database servers. Here is some information that ought to help get you started:

  • The User Guide has a section dedicated to MySQL: User Guide Book 3: Framework, Chapter 4 (Databases), Section 5 (MySQL)
  • Check out the MySQLCommunityServer class in the Language Reference: http://documentation.xojo.com/index.php/MySQLCommunityServer
  • Xojo includes an example project with code to connect to a MySQL database, create a table and add data to it: Database/MySQL/MySQLExample

We also have a YouTube video that walks you through the creation of the above example. It was done using Real Studio, but I bet it will still be helpful: http://youtu.be/kiJpd6FwBcY

It actually was meant to be encouraging. If you know MySQL and therefore SQL you have spent some time learning the nuances of The SQL language. Xojo is no different. It takes some time and effort to wrap your head around.

Try it. When you run into a road block ask a specific question. It isn’t easy to provide a step by step example for a subject as large as “How to make a database application”.

I apologize if my attempt at humor was ill received.

Thanks Peter.
I want an example of a form, a grid, a report, if it is possible.

Aurel, there are such examples - just have a look at Xojo’s Example Projects Folder. People have been giving you plenty of hints now - Examples, the wiki (with very good instructions!) and even videos. What do you want more?