Home > Back-end >  ADOQuery1. Post submission data did not update the database after modification
ADOQuery1. Post submission data did not update the database after modification

Time:09-17

I am beginner, USES the DBGRID DataSource ADOQuery ADOConnection connection mysql database, the database connection is normal, the query is normal, there was a problem modifying data (part of the code below), under the xp with ADOQuery1. Open; ADOQuery1. Edit... ADOQuery1. Post; Normal, can successfully modify the data, but under the Windows 7 error, prompt "data provider or other service return E_FAIL state", modify ADOQuery locktype, under the Windows 7 is not prompt error, but when the program execution DBGRID display data have changed, with the select * from after the refresh data found that the data is not modified, use {} under the Windows 7 code inside the normal, also can successfully modify the data, masters, excuse me how to use ADOQuery1 under Windows 7. The Open; ADOQuery1. Edit... ADOQuery1. Post successfully modify data,
Part of the code is as follows:
If edit1. Text<> "' then
The begin
Memo1. Lines. The Add (");
Memo1. Lines. The Add (' high frequency module);
IdIcmpClient1. Host:=Edit1. Text;
IdIcmpClient1. ReceiveTimeout:=1000;
For the Enabled:=false;
Try
For I:=0 to 1 do
The begin
IdIcmpClient1. Ping;
If (IdIcmpClient1. ReplyStatus. BytesReceived=0) or (IdIcmpClient1. ReplyStatus. TimeToLive=0) then
The begin
With ADOQuery1 do
The begin
{ADOQuery1. Close;
ADOQuery1. SQL. The Clear;
ADOQuery1. SQL. Text:='Update cbat SET state 1="0" where id=' + idh.
ADOQuery1. ExecSQL;
ADOQuery1. Close;
ADOQuery1. SQL. The Clear;
ADOQuery1. SQL. The Add (' select * from cbat order by id ");
ADOQuery1. Open;
ADOQuery1. Locate (' id 'strtoint (idh), [loPartialKey]);
ADOQuery1. EnableControls;
}
ADOQuery1. Open;
ADOQuery1. Edit;
ADOQuery1. FieldByName (' state 1) value:='0';
ADOQuery1. Post;
end;
End
The else
The begin
With ADOQuery1 do
The begin
{ADOQuery1. Close;
ADOQuery1. SQL. The Clear;
ADOQuery1. SQL. Text:='Update cbat SET 1="1" state where id=' + idh.
ADOQuery1. ExecSQL;
ADOQuery1. Close;
ADOQuery1. SQL. The Clear;
ADOQuery1. SQL. The Add (' select * from cbat order by id ");
ADOQuery1. Open;
ADOQuery1. Locate (' id 'strtoint (idh), [loPartialKey]);
ADOQuery1. EnableControls;
}
ADOQuery1. Open;
ADOQuery1. Edit;
ADOQuery1. FieldByName (' state 1) value:='1';
ADOQuery1. Post;
end;
end;
Application. ProcessMessages;
end;
The finally
For the Enabled:=true;
end;
end;

CodePudding user response:

Forgot to say with delphi7 development

CodePudding user response:

Can be related to the Windows 7 system

CodePudding user response:

Estimates that it doesn't matter I also have the Windows 7 no problem completely

CodePudding user response:

Attempts to invalid, hope ace to guide

CodePudding user response:

Basically can determine the post can only modify ADOQuery table, did not change the database

CodePudding user response:

Windows 7 failure. Don't run

CodePudding user response:

Your statement is just modify the first data of the state of '1', rather than specify the ID of the row data 'state 1'

CodePudding user response:

Adoquery1. UpdateBatch (arall); Try to use this

CodePudding user response:

ADOQuery1. SQL. Text:='Update cbat SET state 1="0" where id=' + idh.

1="0" should be state 1=' '0'
'0 respectively with two single quotes on both sides

In addition,
With ADOQuery1 do
The begin
ADOQuery1. Close;//ADOQuery1 can omit
The Close;//this can, with.. Do statement of purpose is to omit
.
end;

CodePudding user response:

What is selected locktype!!!!!!

CodePudding user response:

Look at the data set is modified, additional price updatebatch (arall) try

CodePudding user response:

Through ADOConnection connect to the database, the SQL update operation, Post the statement of a data set that can only update the DBGrid data,

CodePudding user response:

If use the cached data model, you need to use the caching pattern to submit, Post submission is submitted to the cache, not submit to the database, to be submitted to the database, need a ApplyUpdate etc. Function

CodePudding user response:

Simple look under the
And didn't see you for a little, you don't have a positioning line, maybe I don't think the carefully;
Second, database field don't use Chinese as far as possible;
Three, some Settings and Windows 7 XP is not the same, such as the date format will cause the entire software;
Four, adoquery besides query and so on must be set, do not change any Settings, such as locktype
Five, pay attention to your query, the query results in different environments have different effect, if you want to edit the data directly, to avoid the joint query, including federated query view,

CodePudding user response:

Using ado. UpdateBatch (arall);

CodePudding user response:

POS seemingly will only update the DBGRID, try applyupdates look

CodePudding user response:

After the OPEN add FIRST, namely:
With ADOQuery1 do
The begin
The Open;
First;
Edit;
.
Post;
end;

CodePudding user response:

Thank you teacher, recently busy, first temporarily in UPDATE mode, teachers took the time to verify the proposal

CodePudding user response:

Has been completely give up the POST, I felt that this is absolutely a BUG, with test program test alone, useful, an added to the system, the problem it strange that search online method, basic is not available, is insane, simply don't have to,

CodePudding user response:

Return E_FAIL status, basically be the ADO drive OLEDB, suggested by installing MYSQL ODBC, through ODBC to connect again,
  • Related