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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannto figure out TAdoCommand behaviour

Status
Not open for further replies.

B00gyeMan

Programmer
Jan 14, 2004
259
RO
I have tracked a problem down to the execution of a TAdoCommand which uses a stored procedure to insert records in the database.

The point is that the record isn't inserted and no exception is thrown. Due to the fact that the situation appears to occur randomly and rarely it is impossible to debug.

As I understand, some errors (which have severity levels under 11 - according to ms sql documentation) do not cause an exception to be thrown in the user's app code. But can they prevent the record from being inserted? And how can I detect them?

If you have encountered such a behaviour before, or have any ideea, please help me :)
 
I can't guarantee anything but can you show us some code and stored proceedure?

James P. Cottingham
-----------------------------------------
I'm number 1,229!
I'm number 1,229!
 
The stored procedure looks like:
Code:
CREATE PROCEDURE myprocedure
(@var1 NVARCHAR(20),@var2 NVARCHAR(20),@var3 INTEGER,@var4 NVARCHAR(15))
AS
BEGIN
  INSERT INTO myTable (field1, field2, field3, field4) 
  VALUES
  ( @var1, @var2, @var3, @var4)
   IF @@ERROR <> 0
      RETURN (@@ERROR)
   ELSE
   BEGIN
      RETURN (-1)
   END
END


And the code is very simple: the parameters are set, the ParamCheck is set to false, the CommandText i set to the name of the procedure, the command type is set to cmdStoredProc and then the Execute method of the command is called.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top