Android Question SQLiteLight3 ColName query

wjlp

Member
Licensed User
I'm a Programming novice and would be grateful for some help. I have started the B4A tutorials and have reached SQLiteLight3 and have been trying to understand the code. Line 24 suggests that I should be able to change the name of the path, file, database, table etc. I have managed to change the name of the database and table and it displays the table on my device without any problem. But when I change the column name, Line 261 throws up 'No such column: Qty (code 1): while compiling: SELECT ID As [ID],..........' (I used SQLite Expert Personal to make the changes to the database table, and edited ColNames and ColAliasNames in the code to "Qty") It would seem that I have not changed everything that I should have.
 

klaus

Expert
Licensed User
Without seeing what you have done in your code impossible to give you a concrete advice.
Can you post your project with the database as a zip file so I could have a look at it.
 
Upvote 0

wjlp

Member
Licensed User
The project is attached, the previous file tango.zip was a copy of the db file.
 

Attachments

  • SQLiteLight3.zip
    4 KB · Views: 170
Upvote 0

TheMightySwe

Active Member
Licensed User
Dim Cursor1 As Cursor

Cursor1 = SQL.ExecQuery("SELECT * FROM MyTable)

Cursor1.Position = 0

For i = 0 To Cursor1.ColumnCount - 1
Cursor1.Position = i
Cursor1.GetColumnName(i) ' <------

Next

Cursor1.Close
 
Upvote 0

klaus

Expert
Licensed User
When you post a project as a zip file you should use in the IDE menu File / Export As Zip.
To test your project I added the other files from the SQLiteLight3 project from the User's Guide.
On my device it compiles OK, without an error.
I looked at your database, you changed the column name but not the data type nor the values.
 
Upvote 0

wjlp

Member
Licensed User
Hi, thanks for your reply. I'm not sure if I have misunderstood your reply or if I might not have explained my problem very well: I can see that the variable ColNames is showing up correctly without a problem in the Sub ShowTable. My difficulty is in the routine Sub ExecuteHtml that is extracted from the DBUtils where it reads:
cur = SQL.ExecQuery(Query) - when I get to compile this line I get an error:-
- SQLiteException: No such column: Qty (code 1):,while compiling: SELECT [ID], FirstName As [First Name], LastName As [Last Name], Qty As [Qty] from tango
I don't understand why I'm getting this error due to my simple changes to the Variable ColNames(3) i.e. from City to Qty. and TEXT to INTEGER.
I hope this helps to explain my problem
Regards wjlp
 
Upvote 0

klaus

Expert
Licensed User
Post your complete project as a zip file (IDE menu File / Export As Zip) !
When I compile it, it works OK !
So without seeing your full project I can't help you because I cannot reproduce your problem.
 
Upvote 0

wjlp

Member
Licensed User
Thanks for telling me about the IDE/Zip, I should have noticed that. I've enclosed the version that I'm having trouble with. In this version I have changed the ColName, datatype and the data. Hope this helps.
 

Attachments

  • My SQLite from the IDE.zip
    18.7 KB · Views: 145
  • tango.zip
    700 bytes · Views: 122
Upvote 0

wjlp

Member
Licensed User
Woops...I sent the wrong tango.zip (my db file) correct version enclosed with data changes. Can you also please tell me if I should enclose a copy of my db file in zip format ( as I have done) or is this file enclosed automatically in the project upload? It will be useful to know when I send my next plea for help.
 

Attachments

  • tango.zip
    869 bytes · Views: 138
Upvote 0

klaus

Expert
Licensed User
I don't know where your problem is, because the project from post #9 works OK on my device.
I needed to uncomment line 114 the first time to make sure that the database is updated.
The database is in the project zip file.
All files you add in the IDE Files Tab are integrated in the zip file.
Be careful, in the database you defined the Qty column type as Text, but in the code you defined it as Integer !?
 
Upvote 0

wjlp

Member
Licensed User
My thanks again for looking into my problem, much appreciated. It seems as though the difficulty may be associated with the device in some way. I will try to find another one to connect up. If nothing else, I have learned how to communicate with the B4A forum....Cheers.
 
Upvote 0

wjlp

Member
Licensed User
Hi Klaus, apologies for not getting back sooner. I thought that I would delete everything and start from scratch, but that created more problems to sort out. At the moment the emulator appears but does not get any further after 20 minutes.(Any tips?) Never the less my phone device connects using AVD ok and I can run AQLiteLight2 and SQLExample without any problems on the device. However when I try to run AQLiteLight3 the device's screen shows the header 'SQLiteLight3' and the 4 buttons at the bottom, and in the centre of the screen is a note saying...Program paused on line 261 cur = SQL.ExecQuery(Query) It's as if it is waiting for the table/data to be transferred. When I move my mouse over 'cur' on the yellowed Line 261 It reads 'cur not initialised'. I should also mention that I made a clean install before these tests of the 'User Guide' and on this occasion have not tried to make any alterations to the table or variables. (NB I'm a novice...it's probably something I haven't done! should I have loaded any module/file?)
 
Upvote 0

klaus

Expert
Licensed User
Without knowing what exactly you have done it's difficult to give you a concrete advice.
What kind of emulator do you use, what target Android version did you define etc. ?
When you run SQLiteLight3 on your device do you get any Log message, I tested the program again and it works on my device !?
Post the none working project as a zip file (IDE menu File / Export As Zip) and I will have a look at it.
You must be more precise with your questions. What do you test ? What have you done and how ? What are the error messages ? etc. !
 
Upvote 0

wjlp

Member
Licensed User
I have at last managed to get the emulator working. Target Android 4.2.2. API 17 ARM. I think it was a lack of patience on my part! When I run SQLiteLight3 on the emulator it shows the table.
Q1: In emulator edit mode the characters from the table are not showing, only a red line is this normal?

When connected, my device it is not displaying the table, only the header 'SQLiteLight3' and 4 keys are showing on the screen. There is an error message showing on the Log:
android.database.sqlite.SQLiteException: no such column: LastName (code 1): , while compiling: SELECT ID As [ID], FirstName As [First name], LastName As [Last name], City As [City] FROM persons.

Q2: Should there be a Table downloaded to the device as a file?
Q3: Is there a particular directory where I should see this file?
Q4: If there is a file downloaded what is its name?
 

Attachments

  • Problem Project.zip
    18.1 KB · Views: 132
Upvote 0

klaus

Expert
Licensed User
Q1: I downloaded and tested the project from post#16, it works OK on my device.
The table is shown and clicking on the Edit button the data of the selected person is shown.
So I can't give you any advice because I can't reproduce your problem.
Are you sure that this project is the one you tested ?
Q2: The persons.db database file is included in the project. This file is copied to the File.DirInternal directory of the device if it doesn't exist.
Q3: You see it in the Files Tab in the IDE and in the File folder of the project. You cannot see it on the device
Q4: persons.db
 
Upvote 0

wjlp

Member
Licensed User
I have sorted the problem with the emulator not showing text in the edit mode : The reason was that the emulator has a black background and the text colour in the Sub ' InitEditPanel ' is also set at black. Changed to green and all can be seen! Phew now to sort the device out....
 
Upvote 0

wjlp

Member
Licensed User
Found the answer to the problem that I could not get the Table in SQLiteLight3 to show on my device. I added another line to the code in Sub Activity Create(FirstTime). This made the code in SQLiteLight3 similar to the code in SQLiteLight2. (SQLiteLight2 was performing ok on the device) The code in Sub Activity Create(FirstTime). now reads:

'CreateDataBase
File.Copy(File.DirAssets, "persons.db", File.DirInternal, "persons.db")
Else
'if yes, initialize it

Many thanks for your patience Klaus, answering my questions and keeping me thinking about it.
 
Upvote 0
Top