Hi,
For delphi I have this query where I want to input Delphi variables. Ie
So, Im typing in something into the edit box, and choosing something from the Combobox, SQL then searches it. But its not working...Im assuming its to do with the incompatibility with the combbobox/edit box and SQL. Do I have to put some weird signs in to make it work or something?Code:SELECT * FROM (Tablename) WHERE (Combobox1.text) = (Edit1.text)
Thanks
Last edited by Jaan; 11-14-2009 at 06:10 AM. Reason: Please use code tags when you are posting your codes !
myQuery.SQL.Add('SELECT * FROM '+Tablename+' WHERE '+Combobox1.text+' = '''+Edit1.text+'''');
:S
When I enter the table name it goes 'Incompatible types: 'String' and 'TADOtable'
Any ideas?
Thanks
What's your actual code?
This partCode:procedure TFrmDatabase.GoClick(Sender: TObject); begin Searchbox.Text := uppercase(searchbox.Text); dbgrid1.DataSource:= datasource2; adoquery1.SQL.add('SELECT * FROM' +adotable1+ 'WHERE '+Combobox1.text+' = '''+searchbox.text+''''); end;
adotable1 is not a string. Use adotable1.TableName
Right, I've done some messing about and this is really getting on my nerves. I think I found a glitch in my system, look at this:
I put in 4 ' , which should give me 1 ' when it runs, but it gives me 3!!!! I am so angry. I can't believe Ive been stuck on this for like an hour. What is WRONG with this thing? I am SOO close to the finish as well, and it is refusing to cooperate!!
Last edited by 2710; 11-16-2009 at 01:31 PM.
4? shouldn't it be 3?
and do you want the search to be equal, not a LIKE search?
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
Um ' '' ' the outer ones represent display, and the two inner ones represent 1 apostrophe, since if you had one it would represent a 'display' apostrophe, i think.
Um, LIKE is used for similar, I dont want that, I want it to be exactly, so = is fine.
Ok, I've figured out the problem. It's because the field GiftAidID is set as Number in the database, so the string and integer becomes incompatible. So I set it as text in the database and it now works, however, the error still comes up for AmountRaised even if I have set it as a Text.
I'll play around with it.
Thanks for help guys
EDIT: Omg, I dunno what I done, but now it works, yippee lol
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks