Recent

Author Topic: Cannot find table error. [sort of solved]  (Read 2865 times)

Wurlitzer28

  • Newbie
  • Posts: 6
Cannot find table error. [sort of solved]
« on: May 27, 2015, 03:49:24 pm »
Very first attempt at connecting to a new SQLite db from Lazarus.

As part of the learning process I thought I would just use someone else's example code and change the db and table names to see if I could make sense of the Lazarus->db connection process.

I used a sample program I found somewhere on this site and changed the database name to my new DB and also changed the table name [but the name was wrong] and of course I got an error:

"Project project1 raised exception class 'EDatabaseError' with message: no such table: CombinedMasterMusic"

That was the name of the table in my original MS Access db but in the newly created SQLite db it is 'MasterList' Ok that is exactly the error I should have received. So far so good as Lazarus is operating exactly as I expected it to do when I made this error.

So I went to the section of coded in 'unit1.lfm' and changed the table name as such:
object SQLQuery1: TSQLQuery
    FieldDefs = <>
    Database = SQLite3Connection1
    Transaction = SQLTransaction1
    SQL.Strings = (
      'Select * from MasterList'
    )           

Now when I run the code, I don't get any errors after I hit Run but as soon as I hit the button which should launch the code above I get EXACTLY the same error with the same wrong table message. I searched the entire project to see if I had used that same wrong table name elsewhere, even though I thought I had only used it in the code above. I cannot find any reference to 'CombinedMasterMusic'

Just in case, I closed Lazarus and restarted it but the same error with the same wrong table name appeared.

EDIT: Re-booting the laptop fixed this. I trust this will not be a required fix for weird database issues.
« Last Edit: May 30, 2015, 03:39:40 pm by Wurlitzer28 »

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: Cannot find table error.
« Reply #1 on: May 27, 2015, 03:52:47 pm »
Umm, under normal circumstances you shouldn't manually change .lfm files at all. Use Lazarus Object Inspector to change component properties.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Cannot find table error.
« Reply #2 on: May 27, 2015, 04:07:31 pm »
You might want to cleanup the compiled units directory, assuming they're not the same. Otherwise, I can't guess where else the problem might be without touching the source.

Wurlitzer28

  • Newbie
  • Posts: 6
Re: Cannot find table error.
« Reply #3 on: May 27, 2015, 04:28:45 pm »
Umm, under normal circumstances you shouldn't manually change .lfm files at all. Use Lazarus Object Inspector to change component properties.

Thanks guys for the quick reply. The only reasons I changed the table name in the .lfm files was pure newbie ignorance and I looked at every object and could not fine where that reference to the wrong table name existed. HOWEVER as i also did not see the correct table name using the Object Inspector it would seem I did not look in all the right places.

I will go back and check. I thought the full project search would show the faulty table name but it did not.

Thanks again.

 

TinyPortal © 2005-2018