Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add form-parameter to a Query? 1

Status
Not open for further replies.

digitalgerrit

Technical User
Feb 7, 2007
14
NL
Hi there,

I want to use a TQuery object to store data in an Oracle database. I want to insert form-values in the database by setting the querie's SQL-properties about like this: INSERT INTO TABLENAME(COLUMNNAME) VALUES(formvalue)
Does anyone know how to get these formvalues in the SQL-statement?
Any help will be greatly appreciated.
 
Using queries, one way you can do it is like this:

Code:
[navy][i]// for automatic syntax highlighting see faq102-6487 
[/i][/navy][b]with[/b] QueryName [b]do[/b]
Begin
  SQL.Clear;
  SQL.Add([teal]'INSERT INTO TABLENAME (Field1, Field2) VALUES ('[/teal] + QuotedStr(EditBox.TextofStringValue) + [teal]', '[/teal] + EditBox.TextofNumberValue + [teal]')'[/teal]);
  ExecSQL;
[b]end[/b];

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for database developers:
The Fundamentals of Relational Database Design
Understanding SQL Joins
 
Thanks! The code seems to work allright for me when I use a select statement, insert/update/delete statements don't work but I found out this probably is not because the code does not work but because I don't have the appropriate rights on the database I'm working on. I think after I got those rights it should work.
 
just an additional FYI, you use the ExecSQL for insert/update/delete but Active := True for SELECT statements.

Hope you get it all worked out!

Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top