0

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.

Community
  • 1
  • 1
none
  • 4,669
  • 14
  • 62
  • 102
  • 1
    There's no need to vote to close this. It may not be phrased in the best possible way, but it's clear what the OP's problem that he wants help with is. – Mason Wheeler Oct 14 '10 at 16:19
  • AdoQuery is not batch update / insert capable. It will need a post before being able to handle another insert or edit call. Also, if your OtherAdoQuery is connected to a ClientDataSet, the post would be to the ClientDataSet, not the database itself (at least if you are using batch updates). – Marjan Venema Oct 14 '10 at 18:20

2 Answers2

2

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
  • 82,511
  • 50
  • 270
  • 477
  • 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 Oct 14 '10 at 18:18
  • 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 Oct 15 '10 at 00:25
  • the ClientDataSet is at State Browse and seting it to Insert. – none Oct 17 '10 at 11:30
-1

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
  • 4,669
  • 14
  • 62
  • 102