Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Posting to ADOTable problem

Status
Not open for further replies.

MLNorton

Programmer
Nov 15, 2009
134
US
I have a program with two forms. Form 1 is a menu Form that calls Form 2. Form 1 contains an ADOConnection, an ADOTable and a DataSource. These connect to an Access database of 200 records of names and other fields.

Form 2 contains a DBGrid that displays the names. Also on Form 2 there is a DBEdit and three Edits. When a name is selected from the DBGrid the DBEdit displays that name. I then enter values into the three Edits. I have a Post Button with the following:

procedure TForm_Contribute.Button_PostClick(Sender: TObject);
begin
With Form_Main.ADOTable1 do
begin
Cash := Edit_Cash.Text;
Check := Edit_Check.Text;
CheckNum := Edit_CheckNum.Text;
edit;
FieldByName('EnvCash').AsString := Cash;
FieldByName('Check').AsString := Check;
FieldByName('CheckNum').AsString := CheckNum;
post;
end;
end;

When I click Post I get the following message:

…. Exception class EOleException with message, ‘Query is to complex’.

I have been programing in Delphi using databases and ADO for 10 years and have never seen this problem before.

HELP!
 
This can be due to the query being based on a view, or you have a join in the query that makes it difficult for the query to be resolved. The way I usually deal with this, (other than by rewriting queries) is to add an update query and add parameters to the query. You'll probably need to change any dbaware controls for non-db aware counterparts, and when you actually update, set the parameters of your query in the before update.
 
Does ADOTable1 have more than 40 columns. According to Microsoft Support on Access states:

"The error occurs when the cursor library is loaded and the recordset retrieved by the CRecordset is opened as a snapshot object that contains more than 40 bound columns."


Again, a solution is to have a separate query with parameters.
ADOQuery1.SQL.Txt :=
'update <table name> set EnvCash = :pEnvCash, Check = :pCheck, CheckNum = :pCheckNum where recordid = :pRecID'

ADOQuery1.ParamByName('PEnvCash').AsString := Cash;
...
ADOQuery1.ExecSQL;

Then remember to refresh ADOTable1.
 
The Table contains 162 columns. another program has 60 columns and does not havethis problem.
 
It could quite possibly be that 40 is the maximum recommended number of columns, based on this particular error. Maybe it's possible to exceed 40, but *might* cause problems, which in your case, is.


JD Solutions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top