I'm trying to do a TQuery that just executes an SQL statement that the user enters into a TEdit box called edit1.
The SQL statement I'm entering into the TEdit box is as follows: SELECT * FROM "021103.dbf" WHERE EXS = "t"
(021103.dbf is the table displayed by the grid, which I'm querying, and EXS is a valid column heading in the table.)
After I enter this SQL statement and execute it, nothing happens to the DBGrid at all. It doesn't clear, it doesn't
post any new results of any kind, it doesn't change at all from how it previously was (listing the entire table.)
The code for my TQuery is as follows:
Procedure TForm1.TQuery1;
begin
try
// activate the TDatabase component
Database1.Connected := True;
// assign user input as the data value to select
SQLstmt := edit1.Text;
//***********************************************
//Put in the statements to launch the SQLstmt at this point.
Query1.Close; Query1.SQL.Clear;
Query1.SQL.Add(SQLstmt);
Query1.Prepare;
Query1.Open;
//***********************************************
finally
end;
end;
Could anyone please tell me if something is wrong with the SQL statement I'm entering, or if I'm missing a statement
that is required to launch the SQLstmt? It seems that however I change my SQL statement around, nothing works.
Any help would be greatly appreciated, since I have never succeeded in getting a TQuery to return a set of
records to me yet, even an incorrect set.
cold25
The SQL statement I'm entering into the TEdit box is as follows: SELECT * FROM "021103.dbf" WHERE EXS = "t"
(021103.dbf is the table displayed by the grid, which I'm querying, and EXS is a valid column heading in the table.)
After I enter this SQL statement and execute it, nothing happens to the DBGrid at all. It doesn't clear, it doesn't
post any new results of any kind, it doesn't change at all from how it previously was (listing the entire table.)
The code for my TQuery is as follows:
Procedure TForm1.TQuery1;
begin
try
// activate the TDatabase component
Database1.Connected := True;
// assign user input as the data value to select
SQLstmt := edit1.Text;
//***********************************************
//Put in the statements to launch the SQLstmt at this point.
Query1.Close; Query1.SQL.Clear;
Query1.SQL.Add(SQLstmt);
Query1.Prepare;
Query1.Open;
//***********************************************
finally
end;
end;
Could anyone please tell me if something is wrong with the SQL statement I'm entering, or if I'm missing a statement
that is required to launch the SQLstmt? It seems that however I change my SQL statement around, nothing works.
Any help would be greatly appreciated, since I have never succeeded in getting a TQuery to return a set of
records to me yet, even an incorrect set.
cold25