mummi
asked on
How Can I Use The TQuery
Hello!!
I want to do query to a table. Can you show me some examples
Thanks...
I want to do query to a table. Can you show me some examples
Thanks...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks...
an example,
query1.sql.Clear; {Deletes the sql-statement of your query}
query1.sql.add('Select * from Sampletable where Samplefield =' + Yoursamplevalue.asstring; {Add a sql-statement}
try
query1.open; {opens the query}
except
{opening-error occured - your errorhandling}
end;
a datasource connected to the tquery and a dbgrid connected on the datasource and you will see the resultset of your query.
Can handled as a table, except writeback can only done with simple sql-statements (property requestlive = true).
another example
query1.sql.Clear; {Deletes the sql-statement of your query}
query1.sql.add('Delete from Sampletable where Samplefield =' + Yoursamplevalue.asstring; {Add a sql-statement}
try
query1.execsql; {execute sql-statement -> no resultset}
except
{execution-error occured - your errorhandling}
end;
this are simple examples, and if you know about sql, then you can do many things with tquery.
the sql-statementsyntax depends on the database, where you will do a query to the tables in it(paradox, oracle, access ...).
meikl