Solved

How Can I Use The TQuery

Posted on 1999-01-05
3
149 Views
Last Modified: 2010-04-04
Hello!!
I want to do query to a table. Can you show me some examples

Thanks...
0
Comment
Question by:mummi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1354652
hi mummi,

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
0
 

Accepted Solution

by:
mjustin earned 50 total points
ID: 1354653
with Query do
try
    // optional: for SQL server databases
    // if not Prepared then Prepare;
    Close; // in case it is already opened
    SQL.Text := 'your SQL commands go here';
    Open;
    // use it, print it...
finally
    Close;
end;
0
 

Author Comment

by:mummi
ID: 1354654
Thanks...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Printing problem 2 120
Delphi and Access based Enumeration 9 87
Embarcadero C++ builder XE10.1 Berlin find In files dialogue stunted display 4 83
enhance the following code 3 50
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question