3
I have a ADOConnection
, one ADODataSet
, DataSource
, ADOQuery
, one DBGrid
and a DBEdit
.
The DBEdit
is with the property DataField = numero
.
A button with the test:
AdoQuery1.close;
AdoQuery1.SQL.Clear;
AdoQuery1.SQL.Add('select * from tabela WHERE numero=2 ');
AdoQuery1.Open;
Caption := AdoQuery1.fieldbyname('notaTeste').asString;
The SQL command worked correctly as caption shows the expected value.
But it seems that the DBGrid
and the DBEdit
are not bound by ADOQuery
, because after given the SQL command nothing changes in Dbgrid and Dbedit.
What am I doing wrong?
Use Delphi-xe4 professional and database sql-server-2012.
Your question got a little confused. Right at the beginning of the text you already say that the changes made in the
DBGrid
are reflected in theDBEdit
, then says no, and then says it works if it’s withTADODataSet
. Probably your first statement that it works is with theTADODataSet
, right? I don’t really remember how these components work since I work with only the component for a long timeQuery
. But apparently theTADODataSet
already manages everything, but is not very recommended. Already the componentQuery
does not manage other types of request in this way.– user3628
Well, I’ll make it clear.
– Carlos
dbgrid and dbedit are linked correctly with the table. The SQL command in adoquery works. I put the results in the caption to show the test, which is working. However, when performing this select command in tadoquery, I expected only the records belonging to the selection to appear in dbgrid, as if I put the same command in the commandtext property of the tadodataset. That is, the query is executed, but dbgrid and dbedit are not updated.
– Carlos
So you need to edit your question to improve it. Because you can’t understand it. And let me correct a mistake made. Said the
TADODataSet
is not recommended, but I confused component and what I said was unfounded.– user3628
You are most likely commenting on an error that is bringing in more records then. Try taking out the
TADODataSet
of your test project and check the links with theDataSource
.– user3628