Forum > Linux
SQLQuery field not found on ubuntu
Gebo:
I want an id value of an item from sqlquery by this code
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---SQLQuery1.Fields[0].AsInteger; but it show me a message that tell me " SQLQuery field not found ".
that is on ubuntu but It is working on windows.
dseligo:
Did you check if you have records in your query?
Try this:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---If not SQLQuery1.EOF thenbegin // do something with SQLQuery1.Fields[0].AsIntegerendelse ShowMessage('No records.');
Zvoni:
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
Gebo:
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.
rvk:
Try to put some debug logging in your program.
For example... put the following above that line that produces the error:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- Showmessage('FieldCount = ' + SQLQuery1.Fields.Count.ToString); 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.
Navigation
[0] Message Index
[#] Next page