Question

got an ADOQuery that has OnNewRecord event.

on the procedure i try to add data automaticaly to another table. the data is a few rows that are needed and handled in clientDataSet in case of cancellation.

at the loc

OtherAdoQuery.insert;

I get error that ADOQuery failed to insert null into a non null field. I am in insert mode, however I NEVER ASKED DELPHI TO POST! i dont find why it posts.

Edit: could you help me find a hint on this problem?

some more clarification:

at

ADOQuery.onNewRecord();

begin

CliendDataSet.insert; //here goes to post for ADOQueryPost. where ClientDataSet was in Browse State

end;

Edit:

this bug does not make sense! look at the stack trace:

  • beforePost
  • newRecord
  • myFunc

where myFunc does cause NewRecord with the Insert.

Was it helpful?

Solution 2

the answer was from a connection between the tables.

the ADOQuery.dataSource was set the DataSet of the ClientDataSet.

this mad so much damage, and no hint by the delphi.

OTHER TIPS

I'm not too familiar with TAdoQuery, but I know how to track down an error like this. First, if you don't already have it set, go into Project Options and turn on Use Debug DCUs under the Compile tab, then run a full build and run it. When you get that exception report in the debugger, hit Break and you should end up inside the code for the TAdoQuery or one of its sub-objects. Try examining the call stack. If you look up a few calls you'll probably find something that you did is calling something else that's calling Post. Follow the stack trace back until you reach your code and you'll get an idea of what's going on, and if you analyze it a little you should find some way to prevent the problem.

Having said that, let me make a quick guess as to the cause of your problem: When you call Insert on a dataset, if the dataset is already in appending mode because you previously called Insert or Append and didn't follow up with a Post, it will call Post itself before setting up a new row for you to work on. Maybe this is what's happening to you?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top