Recent

Author Topic: SQLQuery field not found on ubuntu  (Read 1327 times)

Gebo

  • New Member
  • *
  • Posts: 46
    • chahpander for lingeries
SQLQuery field not found on ubuntu
« on: September 30, 2024, 08:43:55 am »
I want an id value of an item from sqlquery by this code
Code: Pascal  [Select][+][-]
  1. SQLQuery1.Fields[0].AsInteger;
  2.  
but it show me a message that tell me " SQLQuery field not found ".
that is on ubuntu but It is working on windows.
I like programming I begun by vb,vb.net,c# and finally free pascal and lazarus .I like martial arts sports and I am a kickboxer and made our team sport club called black eagle school I have a website for modern clothes..

dseligo

  • Hero Member
  • *****
  • Posts: 1455
Re: SQLQuery field not found on ubuntu
« Reply #1 on: September 30, 2024, 09:33:59 am »
Did you check if you have records in your query?

Try this:
Code: Pascal  [Select][+][-]
  1. If not SQLQuery1.EOF then
  2. begin
  3.   // do something with SQLQuery1.Fields[0].AsInteger
  4. end
  5. else
  6.   ShowMessage('No records.');

Zvoni

  • Hero Member
  • *****
  • Posts: 2798
Re: SQLQuery field not found on ubuntu
« Reply #2 on: September 30, 2024, 09:49:07 am »
This is not making any sense.
the "content" of a Database (Table, Column) doesn't care if it's "stored" on windows, linux, FreeBSD or my sock-drawer.
Without seeing any Code (specifically the SQL-Statement) it's like gazing into a crystal ball
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Gebo

  • New Member
  • *
  • Posts: 46
    • chahpander for lingeries
Re: SQLQuery field not found on ubuntu
« Reply #3 on: September 30, 2024, 09:50:37 am »
I already have 3 records but I want to delete a record that user selected on dbgrid by id .
I want to get the id field of the record selected to delete it by sql query statement.
I like programming I begun by vb,vb.net,c# and finally free pascal and lazarus .I like martial arts sports and I am a kickboxer and made our team sport club called black eagle school I have a website for modern clothes..

rvk

  • Hero Member
  • *****
  • Posts: 6643
Re: SQLQuery field not found on ubuntu
« Reply #4 on: September 30, 2024, 10:51:53 am »
Try to put some debug logging in your program.

For example... put the following above that line that produces the error:

Code: Pascal  [Select][+][-]
  1.   Showmessage('FieldCount = ' + SQLQuery1.Fields.Count.ToString);
  2.   Showmessage('Fields[0].FieldName = ' + SQLQuery1.Fields[0].FieldName);

If the first gives you FieldCount > 0 then the second should work.
If the first gives you 0 then you don't have any fields defined.

The field definition should be done automatically during opening (if they are not predefined by you).

I normally use SQLQuery1.FieldByName('id').AsInteger to get to a particular field.
(Much easier than assuming the first field is the one you want)

If it still doesn't work then you need to show more code.

Gebo

  • New Member
  • *
  • Posts: 46
    • chahpander for lingeries
Re: SQLQuery field not found on ubuntu
« Reply #5 on: September 30, 2024, 12:48:11 pm »
when I use showmessage It shows me the field name "id" but when use
Code: Pascal  [Select][+][-]
  1. SQLQuery1.FieldByName('id').AsInteger
  2.  
I get the message sqlquery field not found.
I like programming I begun by vb,vb.net,c# and finally free pascal and lazarus .I like martial arts sports and I am a kickboxer and made our team sport club called black eagle school I have a website for modern clothes..

nummer8

  • Full Member
  • ***
  • Posts: 124
Re: SQLQuery field not found on ubuntu
« Reply #6 on: September 30, 2024, 12:51:16 pm »
What is the SqlQuery1.SQL.Text ?

dseligo

  • Hero Member
  • *****
  • Posts: 1455
Re: SQLQuery field not found on ubuntu
« Reply #7 on: September 30, 2024, 01:09:42 pm »
when I use showmessage It shows me the field name "id" but when use

I am not sure I understand this. Are you saying that 'SQLQuery1.Fields[0].AsInteger;' works and that 'SQLQuery1.FieldByName('id').AsInteger' doesn't work?

Quote
Code: Pascal  [Select][+][-]
  1. SQLQuery1.FieldByName('id').AsInteger
  2.  
I get the message sqlquery field not found.

Did you test SQLQuery1.Eof as in reply #1?

Thaddy

  • Hero Member
  • *****
  • Posts: 16411
  • Censorship about opinions does not belong here.
Re: SQLQuery field not found on ubuntu
« Reply #8 on: September 30, 2024, 01:11:54 pm »
Can it just be a matter of CASE, like ID?
There is nothing wrong with being blunt. At a minimum it is also honest.

Zvoni

  • Hero Member
  • *****
  • Posts: 2798
Re: SQLQuery field not found on ubuntu
« Reply #9 on: September 30, 2024, 01:16:46 pm »
Why don't we just play a bit of Lottery, or throw some dice around?

UNTIL TS SHOWS HIS DAMNED SQL-Statement!
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Thaddy

  • Hero Member
  • *****
  • Posts: 16411
  • Censorship about opinions does not belong here.
Re: SQLQuery field not found on ubuntu
« Reply #10 on: September 30, 2024, 01:18:56 pm »
Good point.
There is nothing wrong with being blunt. At a minimum it is also honest.

dseligo

  • Hero Member
  • *****
  • Posts: 1455
Re: SQLQuery field not found on ubuntu
« Reply #11 on: September 30, 2024, 01:30:31 pm »
Why don't we just play a bit of Lottery, or throw some dice around?

UNTIL TS SHOWS HIS DAMNED SQL-Statement!

And what RDBMS he use.

rvk

  • Hero Member
  • *****
  • Posts: 6643
Re: SQLQuery field not found on ubuntu
« Reply #12 on: September 30, 2024, 02:55:54 pm »
when I use showmessage It shows me the field name "id" but when use
Code: Pascal  [Select][+][-]
  1. SQLQuery1.FieldByName('id').AsInteger
  2.  
I get the message sqlquery field not found.
And also show EXACT error message and the relevant pascal code.
It could just be a typo in your code.

Gebo

  • New Member
  • *
  • Posts: 46
    • chahpander for lingeries
Re: SQLQuery field not found on ubuntu
« Reply #13 on: October 13, 2024, 09:08:49 am »
Thanks all.
the problem is I was close sqlquery and change sql statement then I write the line code.
I fixed it by using a variable.
I like programming I begun by vb,vb.net,c# and finally free pascal and lazarus .I like martial arts sports and I am a kickboxer and made our team sport club called black eagle school I have a website for modern clothes..

 

TinyPortal © 2005-2018