I am fairly new to Xojo and have a couple of problems with retrieving data from an SQLite database. The database is a simple one table affair with fields for first, last and full names and a primary key index; I’m using it purely as a trial for functionality of SQL commands.
The first issue I have involves retrieving data from a record using SELECT and WHERE and the first (or last or full) name. The syntax used is -
Dim rs as RecordSet
rs = db.SQLSelect("SELECT * FROM Names WHERE First = ‘Fred’ ")
If the record has been inserted manually using a database editor such as “DB Browser for SQLite”, retrieval is successful; if the record has been created by means of code using the INSERT INTO command, retrieval fails - no error message, it just doesn’t work. I notice also that if one looks at the records with the browser, those fields which have been inserted by code means are indented by a one character space compared with those created manually . I’m not sure whether this is significant.
The other issue concerns retrieving data where the WHERE criterion is supplied by means of a Text Field using the syntax -
Dim rs as RecordSet
rs = db.SQLSelect(“SELECT * FROM TableName WHERE fieldname =” + TFName.Text). This works fine with numeric fields but with text fields it stubbornly refuses to return the requisite data.
I’m sure the answer is perfectly simple, but so far has has completely eluded me. I really would appreciate some advice.