views:

75

answers:

2

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 clearfication:

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.

+2  A: 

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?

Mason Wheeler
Good guess I think. ADOQuery doesn't support batch inserts and would have to do a post before it would be able to handle a second insert. On the other hand, I'd expect it to raise an exception on the second insert... but maybe that was a couple of ADO versions back :-)
Marjan Venema
delphi 7 adodb version. im useing eruka log, with the delphi as a main error thrower and handler. ill check it on sunday. thanks
none
the ClientDataSet is at State Browse and seting it to Insert.
none
A: 

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.

none