Weird Debugging issue

  • Thread starter Thread starter Rob T
  • Start date Start date
R

Rob T

I have a collection of objects that I'm using to keep track of general
ledger (GL) entires. Each object in the collection is one GL entry. I then
have a function that will add up all the debits and credits (positives and
negatives) entries to make sure they all balance.

To do this, I create a temporary table in SQL server, then insert the values
of each object into the table, and then do a summary of the debit and credit
columns. If the debit & credit columns match, the transaction is valid.

So, this routine works perfectly EXCEPT for when I'm trying to debug it in
VS. When I step through the code, when the code performs the Insert into
table, it inserts the value 4 to 6 times....even though the code only
executes one time. The code is simple: I open the connection, perform the
insert, and close the connection.

Why when I'm stepping through, does it do this?

Additional Notes:
- It doesn't matter if I'm inserting into a temp or a regular table.
- I have an identiy field in the table, so you can actually see it increase
for each record that was entered...even though the code only stepping
through once!

Thanks

-Rob T.
 
Without examining the code, I can only guess.

If you are SQL Server, you can switch to XML to enter values. If not, you
can use a DataSet and have the DataAdapter update the insert table (not as
easy with a true temp table). Both avoid individual inserts.

If you move to stored procedures, you have the option of stepping through
sproc code, which may be a better option, but this is far easier in Visual
Studio 2005, which is not released until Nov 7.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Please post your code, and make special note of any variables you may be
changing when debug.

When you are stepping through the code, is the code actually calling the
insert multiple times, or is it calling the insert once and SQL Server is
duplicating the rows?

Also, are you using a SQL insert statement or calling a stored procedure?

Do you have any triggers on the table/tables that you are updating?

Include the code for the stored proc and the triggers if you have any.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top