Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8843773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:18:59+00:00 2026-06-14T11:18:59+00:00

Every time when I use debugger, one of my stored procedures is executed, even

  • 0

Every time when I use debugger, one of my stored procedures is executed, even when I stop the debugger before reaching the line of code responsible for saving data to the database.

How could I prevent this from happening? I don’t want to have incomplete rows in the database.

POrder po = new POrder();          
po.PODate = DateTime.Parse(txtPODate.Text);  <-- Breakpoint here

po.POVendorID = int.Parse(ddPOVendors.SelectedValue);  <-- Stop Debugging here 

I am not reaching po.AddNewOrder yet and I stop the debugger, so I am not executing the stored procedure yet

po.AddNewOrder();

POrder class:

    public DateTime  PODate { get; set; }
    public int POVendorID { get; set; }

    public void AddNewOrder()
    {
        SqlConnection con = new SqlConnection(ss.GetConectionString());

        SqlCommand cmd = new SqlCommand("uspAddNewPOrder", con);
        cmd.CommandType = CommandType.StoredProcedure;

        SqlParameter parPODate = new SqlParameter("@PODate", SqlDbType.Date);
        parPODate.Value = PODate;
        cmd.Parameters.Add(parPODate);

        SqlParameter parPOVendorID = new SqlParameter("@POVendorID", SqlDbType.Int);
        parPOVendorID.Value = POVendorID;
        cmd.Parameters.Add(parPOVendorID);

        try
        {
            con.Open();
            cmd.ExecuteNonQuery();
        }
        catch (Exception exp) 
        {
            throw new Exception(exp.Message.ToString());
        }
        finally
        {
            cmd.Dispose();
            con.Close();
        }
    }

Stored procedure code:

ALTER PROCEDURE [dbo].[uspAddNewPOrder] 
(
        @PODate datetime = null,
        @POVendorID int= null
)
AS
BEGIN
    INSERT INTO PurchaseOrders.[dbo].[tblPurchaseOrders]
    (
       PODate,
       POVendorID

    )
    VALUES
    (
       @PODate,
       @POVendorID
    )
END
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:19:01+00:00Added an answer on June 14, 2026 at 11:19 am

    You can use preprocessor directives to skip a sections of code executing given a condition (ex; during debugging in your case). Have a look at this MSDN link

    #define DEBUG
    public class YourClass 
    {
        POrder po = new POrder();          
        po.PODate = DateTime.Parse(txtPODate.Text);
        Break point here ->
    
        po.POVendorID = int.Parse(ddPOVendors.SelectedValue);
        #if (!DEBUG)
            po.AddNewOrder(); //this will not be executed during debug.
        #endif
        ....      
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out something - Every time I use AVAudioPlayer I
Every time i pass some parameters to a JavasScript or jQuery functon, i use
I have to type rvm use ruby-1.9.3 every time I login to my server.
I use VS 2005 and VSS 2005. Every time I close VS I get
I use codefirst and I use Elmah. I recreated every time the database, you
I use cast() from the reshape package quite frequently. Almost every time, this warning
My script does not seem to be working. Every time i try to use
OK I love Python's zip() function. Use it all the time, it's brilliant. Every
If I only ever use one Statement at a time would it be worthwhile
Every time I use Math.Round/Floor/Ceiling I always cast to int (or perhaps long if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.