First time here? Check out the FAQ!

Inserting SQL query in a button.

0 votes
asked by about Borland Delphi 7 Lite Full Edition
edited by

I want to insert a SQL query in a button. When clicked on button, the query should activate and display the database in a dbGrid.

1 Answer

0 votes
answered by (264k points)

To properly use SQL query in a button, first you need to make sure that everything is connected. Without connection to database, this isn't possible. You can assign the functions to make the connection into the code then use:

procedure TForm1.Button1Click(Sender: TObject);
ADOQuery1.SQL.Text := Memo1.Text;

then in object inspector code add the following text:

Grid.DataSource = DataSource1;
DataSource1.DataSet := ADOQuery1;

This means that the Grid needs to be connected to the TDatasource and TDatasource to ADOQuery1.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register