Stop Debugging doesn't stop in ASP.NET

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Stop Debugging doesn't stop in ASP.NET

    While stepping through an ASP.NET project, I found that data was being
    inserted into my database even though I was not stepping through the
    code that inserted the data.

    I have a single page with inline code. The page has a Datagrid, a
    textbox and a button. When the button is clicked, the value of the
    textbox is inserted into the table whose contents are displayed on the
    page.

    The problem occurs when I set a breakpoint on a line *IN* the Button1
    click event. The line with the breakpoint is *IN* the event, but before
    any database code is called. When the breakpoint is hit, I click the
    'Stop' button, to end the debugging session. Because I have not yet
    stepped through any database insertion code, I expect that no values
    will be inserted in the database.

    However, it appears that once the event is fired (the breakpoint is
    *INSIDE* the click event), the whole event code is executed, even though
    the Stop button was pressed.

    Is there a way to force the ASP.NET debugging session to actually end
    when I stop debugging?

    Thanks

    MATT

    Code to reproduce the behavior included below.

    <!-- BEGIN CODE -->

    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
    <HTML>
    <script language="VB" runat="server">
    private msConn as string

    Sub Page_Load(Sender As Object, E As EventArgs)
    #If DEBUG Then
    Stop
    'Check the contents of the Categories table in the Northwind
    database so that
    ' you will know when a new value has been inserted.
    #End If
    BindData()
    End Sub
    Sub Button1_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs)
    #IF DEBUG THEN
    STOP

    'Notice that we have not stepped through any code that will
    insert
    ' values into the database.
    'Use SQL Enterprise Manager to examine the contents of the
    Categories
    ' table of the Northwind database. There should not be
    any new values
    'To test the db insert, click Debug | Stop Debugging to stop
    the project.
    ' Then hit F5 to restart the project and view the contents
    of the
    ' drop down list.
    'You will see that the value in the text box is now included
    in the
    ' data grid. The value from the text box was written to
    the db
    ' even though we did not call any code that would insert
    to the db.
    #END IF

    Dim Cmd As SqlClient.SqlCommand
    Dim sSQL As String
    Try
    Cmd = New SqlClient.SqlCommand()
    sSQL = "INSERT INTO Categories(CategoryName) VALUES('" &
    Me.txtCategory.Text & "')"
    With Cmd
    .CommandText = sSQL
    .CommandType = CommandType.Text
    .Connection = New SqlClient.SqlConnection(msConn)
    .Connection.Open()

    .ExecuteNonQuery()
    .Connection.Close()
    End With

    'Refresh
    BindData()

    Catch exp As Exception
    Throw exp
    Finally
    Cmd.Connection.Close()
    End Try
    End Sub

    Private Sub BindData()
    Dim DS As DataSet
    Dim MyConnection As SqlConnection
    Dim MyCommand As SqlDataAdapter
    msConn = "server=(local);database=Northwind;user id = sa;"
    MyConnection = New SqlConnection(msConn)
    MyCommand = New SqlDataAdapter("select * from Categories",
    MyConnection)

    DS = New DataSet()
    MyCommand.Fill(DS, "Categories")

    MyDataList.DataSource = DS.Tables("Categories").DefaultView
    MyDataList.DataBind()
    End Sub
    </script>
    <body>
    <form id="Form1" method="post" runat="server">
    <b>Category ID | Category </b>
    <br>
    <ASP:DataList id="MyDataList" RepeatColumns="1" runat="server"
    BorderColor="#CC9966" BorderStyle="None" BackColor="White"
    CellPadding="4" GridLines="Both" BorderWidth="1px">
    <ItemTemplate>
    <DIV style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; FONT-SIZE: 10pt;
    PADDING-BOTTOM: 5px; PADDING-TOP: 5px; FONT-FAMILY: Verdana">
    <%# DataBinder.Eval(Container.DataItem, "categoryid") %>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |
    &nbsp;&nbsp;&nbsp;&nbsp;<%# DataBinder.Eval(Container.DataItem,
    "CategoryName") %></DIV>
    </ItemTemplate>
    </ASP:DataList>
    <asp:TextBox id="txtCategory" runat="server"></asp:TextBox>
    <asp:Button id="Button1" runat="server" Text="Button"
    OnClick="Button1_Click"></asp:Button>
    </form>
    </body>
    </HTML>

    <!-- END CODE -->




    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Matt Theule Guest

  2. Similar Questions and Discussions

    1. STOP=Save The Opticles People! ... Stop Flashs flashing!
      :| WHEN will they ever learn, our eyes are not to be played with. Imagin putting on a blindfold on for 1 - 24hr period & TRY to go about there...
    2. cannot stop debugging info in mac browsers
      We have always used ip adresses (setting in cf administrator ) to control the display of debug info. Recently we started getting reports that...
    3. stop
      > I've requested 50 times to be taken off your mailing list, You've sent 50 emails to beginners-unsubscribe@perl.org? I get no spam from this...
    4. Stop at 518 on 43P
      Hello, A partner has a 335MhZ 43P that will not boot... the white screen keeps hanging at 518. We switch it on, it finds the hardware...
    5. Replication - ASNCMD "DBNAME" STOP does not stop Capure
      I am running DB2 version 7.2, when I execute ASNCMD dbname STOP. 8 out of ten times Capture will bring itself down. I need this to work 100% of...
  3. #2

    Default Re: Stop Debugging doesn't stop in ASP.NET

    Matt,

    I would be very surprised if the debugger is continuing after you click
    "Stop".

    I suggest you add something like this:

    throw new Exception("Try getting past this!");

    on the line after your breakpoint. Hit "Stop" and see what happens.

    Also, be _really_ sure that the "added" record is actually being added when
    you think it is. For instance, if your table uses an identity column for the
    primary key, check the highest key before and after your test.

    I might also try commenting out the database insert code entirely. If it's
    not there, and if the record got inserted, then it wasn't inserted by the
    (non-existant) database insert code.

    --
    John Saunders
    Internet Engineer
    [email]john.saunders@surfcontrol.com[/email]


    "Matt Theule" <usenet at mattsolutions dot com_> wrote in message
    news:%23o92t0VUDHA.1664@TK2MSFTNGP11.phx.gbl...
    > While stepping through an ASP.NET project, I found that data was being
    > inserted into my database even though I was not stepping through the
    > code that inserted the data.
    >
    > I have a single page with inline code. The page has a Datagrid, a
    > textbox and a button. When the button is clicked, the value of the
    > textbox is inserted into the table whose contents are displayed on the
    > page.
    >
    > The problem occurs when I set a breakpoint on a line *IN* the Button1
    > click event. The line with the breakpoint is *IN* the event, but before
    > any database code is called. When the breakpoint is hit, I click the
    > 'Stop' button, to end the debugging session. Because I have not yet
    > stepped through any database insertion code, I expect that no values
    > will be inserted in the database.
    >
    > However, it appears that once the event is fired (the breakpoint is
    > *INSIDE* the click event), the whole event code is executed, even though
    > the Stop button was pressed.
    >
    > Is there a way to force the ASP.NET debugging session to actually end
    > when I stop debugging?
    >
    > Thanks
    >
    > MATT
    >
    > Code to reproduce the behavior included below.
    >
    > <!-- BEGIN CODE -->
    >
    > <%@ Import Namespace="System.Data" %>
    > <%@ Import Namespace="System.Data.SqlClient" %>
    > <HTML>
    > <script language="VB" runat="server">
    > private msConn as string
    >
    > Sub Page_Load(Sender As Object, E As EventArgs)
    > #If DEBUG Then
    > Stop
    > 'Check the contents of the Categories table in the Northwind
    > database so that
    > ' you will know when a new value has been inserted.
    > #End If
    > BindData()
    > End Sub
    > Sub Button1_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs)
    > #IF DEBUG THEN
    > STOP
    >
    > 'Notice that we have not stepped through any code that will
    > insert
    > ' values into the database.
    > 'Use SQL Enterprise Manager to examine the contents of the
    > Categories
    > ' table of the Northwind database. There should not be
    > any new values
    > 'To test the db insert, click Debug | Stop Debugging to stop
    > the project.
    > ' Then hit F5 to restart the project and view the contents
    > of the
    > ' drop down list.
    > 'You will see that the value in the text box is now included
    > in the
    > ' data grid. The value from the text box was written to
    > the db
    > ' even though we did not call any code that would insert
    > to the db.
    > #END IF
    >
    > Dim Cmd As SqlClient.SqlCommand
    > Dim sSQL As String
    > Try
    > Cmd = New SqlClient.SqlCommand()
    > sSQL = "INSERT INTO Categories(CategoryName) VALUES('" &
    > Me.txtCategory.Text & "')"
    > With Cmd
    > .CommandText = sSQL
    > .CommandType = CommandType.Text
    > .Connection = New SqlClient.SqlConnection(msConn)
    > .Connection.Open()
    >
    > .ExecuteNonQuery()
    > .Connection.Close()
    > End With
    >
    > 'Refresh
    > BindData()
    >
    > Catch exp As Exception
    > Throw exp
    > Finally
    > Cmd.Connection.Close()
    > End Try
    > End Sub
    >
    > Private Sub BindData()
    > Dim DS As DataSet
    > Dim MyConnection As SqlConnection
    > Dim MyCommand As SqlDataAdapter
    > msConn = "server=(local);database=Northwind;user id = sa;"
    > MyConnection = New SqlConnection(msConn)
    > MyCommand = New SqlDataAdapter("select * from Categories",
    > MyConnection)
    >
    > DS = New DataSet()
    > MyCommand.Fill(DS, "Categories")
    >
    > MyDataList.DataSource = DS.Tables("Categories").DefaultView
    > MyDataList.DataBind()
    > End Sub
    > </script>
    > <body>
    > <form id="Form1" method="post" runat="server">
    > <b>Category ID | Category </b>
    > <br>
    > <ASP:DataList id="MyDataList" RepeatColumns="1" runat="server"
    > BorderColor="#CC9966" BorderStyle="None" BackColor="White"
    > CellPadding="4" GridLines="Both" BorderWidth="1px">
    > <ItemTemplate>
    > <DIV style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; FONT-SIZE: 10pt;
    > PADDING-BOTTOM: 5px; PADDING-TOP: 5px; FONT-FAMILY: Verdana">
    > <%# DataBinder.Eval(Container.DataItem, "categoryid") %>
    > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |
    > &nbsp;&nbsp;&nbsp;&nbsp;<%# DataBinder.Eval(Container.DataItem,
    > "CategoryName") %></DIV>
    > </ItemTemplate>
    > </ASP:DataList>
    > <asp:TextBox id="txtCategory" runat="server"></asp:TextBox>
    > <asp:Button id="Button1" runat="server" Text="Button"
    > OnClick="Button1_Click"></asp:Button>
    > </form>
    > </body>
    > </HTML>
    >
    > <!-- END CODE -->
    >
    >
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    John Saunders Guest

  4. #3

    Default Re: Stop Debugging doesn't stop in ASP.NET

    i can kinda see his point, most times if you stop on a line before an
    assignment in the debugger, the debugger has already made the assignment and
    is showing it in the watch window. go figure. something is strange indeed.

    "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    news:ex667sWUDHA.2148@TK2MSFTNGP11.phx.gbl...
    > Matt,
    >
    > I would be very surprised if the debugger is continuing after you click
    > "Stop".
    >
    > I suggest you add something like this:
    >
    > throw new Exception("Try getting past this!");
    >
    > on the line after your breakpoint. Hit "Stop" and see what happens.
    >
    > Also, be _really_ sure that the "added" record is actually being added
    when
    > you think it is. For instance, if your table uses an identity column for
    the
    > primary key, check the highest key before and after your test.
    >
    > I might also try commenting out the database insert code entirely. If it's
    > not there, and if the record got inserted, then it wasn't inserted by the
    > (non-existant) database insert code.
    >
    > --
    > John Saunders
    > Internet Engineer
    > [email]john.saunders@surfcontrol.com[/email]
    >
    >
    > "Matt Theule" <usenet at mattsolutions dot com_> wrote in message
    > news:%23o92t0VUDHA.1664@TK2MSFTNGP11.phx.gbl...
    > > While stepping through an ASP.NET project, I found that data was being
    > > inserted into my database even though I was not stepping through the
    > > code that inserted the data.
    > >
    > > I have a single page with inline code. The page has a Datagrid, a
    > > textbox and a button. When the button is clicked, the value of the
    > > textbox is inserted into the table whose contents are displayed on the
    > > page.
    > >
    > > The problem occurs when I set a breakpoint on a line *IN* the Button1
    > > click event. The line with the breakpoint is *IN* the event, but before
    > > any database code is called. When the breakpoint is hit, I click the
    > > 'Stop' button, to end the debugging session. Because I have not yet
    > > stepped through any database insertion code, I expect that no values
    > > will be inserted in the database.
    > >
    > > However, it appears that once the event is fired (the breakpoint is
    > > *INSIDE* the click event), the whole event code is executed, even though
    > > the Stop button was pressed.
    > >
    > > Is there a way to force the ASP.NET debugging session to actually end
    > > when I stop debugging?
    > >
    > > Thanks
    > >
    > > MATT
    > >
    > > Code to reproduce the behavior included below.
    > >
    > > <!-- BEGIN CODE -->
    > >
    > > <%@ Import Namespace="System.Data" %>
    > > <%@ Import Namespace="System.Data.SqlClient" %>
    > > <HTML>
    > > <script language="VB" runat="server">
    > > private msConn as string
    > >
    > > Sub Page_Load(Sender As Object, E As EventArgs)
    > > #If DEBUG Then
    > > Stop
    > > 'Check the contents of the Categories table in the Northwind
    > > database so that
    > > ' you will know when a new value has been inserted.
    > > #End If
    > > BindData()
    > > End Sub
    > > Sub Button1_Click(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs)
    > > #IF DEBUG THEN
    > > STOP
    > >
    > > 'Notice that we have not stepped through any code that will
    > > insert
    > > ' values into the database.
    > > 'Use SQL Enterprise Manager to examine the contents of the
    > > Categories
    > > ' table of the Northwind database. There should not be
    > > any new values
    > > 'To test the db insert, click Debug | Stop Debugging to stop
    > > the project.
    > > ' Then hit F5 to restart the project and view the contents
    > > of the
    > > ' drop down list.
    > > 'You will see that the value in the text box is now included
    > > in the
    > > ' data grid. The value from the text box was written to
    > > the db
    > > ' even though we did not call any code that would insert
    > > to the db.
    > > #END IF
    > >
    > > Dim Cmd As SqlClient.SqlCommand
    > > Dim sSQL As String
    > > Try
    > > Cmd = New SqlClient.SqlCommand()
    > > sSQL = "INSERT INTO Categories(CategoryName) VALUES('" &
    > > Me.txtCategory.Text & "')"
    > > With Cmd
    > > .CommandText = sSQL
    > > .CommandType = CommandType.Text
    > > .Connection = New SqlClient.SqlConnection(msConn)
    > > .Connection.Open()
    > >
    > > .ExecuteNonQuery()
    > > .Connection.Close()
    > > End With
    > >
    > > 'Refresh
    > > BindData()
    > >
    > > Catch exp As Exception
    > > Throw exp
    > > Finally
    > > Cmd.Connection.Close()
    > > End Try
    > > End Sub
    > >
    > > Private Sub BindData()
    > > Dim DS As DataSet
    > > Dim MyConnection As SqlConnection
    > > Dim MyCommand As SqlDataAdapter
    > > msConn = "server=(local);database=Northwind;user id = sa;"
    > > MyConnection = New SqlConnection(msConn)
    > > MyCommand = New SqlDataAdapter("select * from Categories",
    > > MyConnection)
    > >
    > > DS = New DataSet()
    > > MyCommand.Fill(DS, "Categories")
    > >
    > > MyDataList.DataSource = DS.Tables("Categories").DefaultView
    > > MyDataList.DataBind()
    > > End Sub
    > > </script>
    > > <body>
    > > <form id="Form1" method="post" runat="server">
    > > <b>Category ID | Category </b>
    > > <br>
    > > <ASP:DataList id="MyDataList" RepeatColumns="1" runat="server"
    > > BorderColor="#CC9966" BorderStyle="None" BackColor="White"
    > > CellPadding="4" GridLines="Both" BorderWidth="1px">
    > > <ItemTemplate>
    > > <DIV style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; FONT-SIZE: 10pt;
    > > PADDING-BOTTOM: 5px; PADDING-TOP: 5px; FONT-FAMILY: Verdana">
    > > <%# DataBinder.Eval(Container.DataItem, "categoryid") %>
    > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |
    > > &nbsp;&nbsp;&nbsp;&nbsp;<%# DataBinder.Eval(Container.DataItem,
    > > "CategoryName") %></DIV>
    > > </ItemTemplate>
    > > </ASP:DataList>
    > > <asp:TextBox id="txtCategory" runat="server"></asp:TextBox>
    > > <asp:Button id="Button1" runat="server" Text="Button"
    > > OnClick="Button1_Click"></asp:Button>
    > > </form>
    > > </body>
    > > </HTML>
    > >
    > > <!-- END CODE -->
    > >
    > >
    > >
    > >
    > > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > > Don't just participate in USENET...get rewarded for it!
    >
    >

    Alvin Bruney Guest

  5. #4

    Default Re: Stop Debugging doesn't stop in ASP.NET

    > i can kinda see his point, most times if you stop on a
    > line before an assignment in the debugger, the debugger
    > has already made the assignment and is showing it in the
    > watch window.
    Interesting. I've never noticed that.

    I have noticed the debugger displaying the old value of a variable in
    the Autos window when you break before the assignment, and the new value
    when you single-step past it. But I've never noticed it showing the new
    value before it's set.


    John Saunders
    [email]john.saunders@surfcontrol.com[/email]

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    John Saunders Guest

  6. #5

    Default Re: Stop Debugging doesn't stop in ASP.NET

    >I would be very surprised if the debugger is
    >continuing after you click "Stop".
    Yes, I am too, but that is what is happening.

    I added the throw new exception code you suggested to the code I posted
    in my original message. When I hit the break point *INSIDE* the event
    handler before the exception throwing, I clicked the "Stop" button. I
    very briefly saw the web page change to the yellow, white and red of an
    exception. At the top of the page was "Try to get past this". Then the
    browser closed as the project finished stopping.

    I emphasize that the break point must be inside the event handling
    method because if you put the break point on the 'Public Sub
    Button1_Click (byval ...' line, and click the stop button, the project
    stops as expected, and nothing surprising happens. It is as if once the
    event handler code has been engaged to any degree, Visual Studio is
    committed to completing the method, even after the stop button is
    pressed.

    Please run the demo that I posted in my original message. I have
    included STOP commands with notes to check the db at various points.
    The code uses the Categories table of the Northwind database. The code
    is very simple and straight forward so there is no possibility that the
    data could be inserted from a different method. The Categories table
    does in fact use an identity column, so it is easy to see that there is
    a new, higher identity category in the table.

    Thanks

    MATT




    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Matt Theule Guest

  7. #6

    Default Re: Stop Debugging doesn't stop in ASP.NET

    You are right, of course, the database access does add a layer of
    complexity. However, the database access also allows for persistence of
    results.

    Below you will find a stripped down version that includes only the
    throwing of a new exception.

    I only very briefly see the exception displayed in the browser, and I
    would imagine on a faster machine (I am running PIII - 1 GHz, 512 RAM)
    that it would be even harder to see the display of the exception, making
    the exception seem not to appear.

    On my co-worker's P4 1.5 Mhz 256 RAM, the exception was visible, again,
    only briefly. 2 monitors made it easier to see.

    Thanks

    MATT

    <!-- BEGIN CODE -->
    <HTML>
    <script language="VB" runat="server">
    Sub Page_Load(Sender As Object, E As EventArgs)
    End Sub
    Sub Button1_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs)
    #IF DEBUG THEN
    STOP
    'Click the "Stop Debugging" button and watch the browser display
    ' the exception below.
    #END IF
    throw new exception("Try to get past this!")
    End Sub
    </script>
    <body>
    <form id="Form1" method="post" runat="server">
    <asp:Button id="Button1" runat="server" Text="Button"
    OnClick="Button1_Click"></asp:Button>
    </form>
    </body>
    </HTML>
    <!-- END CODE -->

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Matt Theule Guest

  8. #7

    Default Re: Stop Debugging doesn't stop in ASP.NET

    Matt, does the same problem happen if you don't use STOP, but instead set a
    breakpoint in the debugger?

    --
    John Saunders
    Internet Engineer
    [email]john.saunders@surfcontrol.com[/email]


    "Matt Theule" <usenet at mattsolutions dot com_> wrote in message
    news:e0KYK6gUDHA.1012@TK2MSFTNGP11.phx.gbl...
    > You are right, of course, the database access does add a layer of
    > complexity. However, the database access also allows for persistence of
    > results.
    >
    > Below you will find a stripped down version that includes only the
    > throwing of a new exception.
    >
    > I only very briefly see the exception displayed in the browser, and I
    > would imagine on a faster machine (I am running PIII - 1 GHz, 512 RAM)
    > that it would be even harder to see the display of the exception, making
    > the exception seem not to appear.
    >
    > On my co-worker's P4 1.5 Mhz 256 RAM, the exception was visible, again,
    > only briefly. 2 monitors made it easier to see.
    >
    > Thanks
    >
    > MATT
    >
    > <!-- BEGIN CODE -->
    > <HTML>
    > <script language="VB" runat="server">
    > Sub Page_Load(Sender As Object, E As EventArgs)
    > End Sub
    > Sub Button1_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs)
    > #IF DEBUG THEN
    > STOP
    > 'Click the "Stop Debugging" button and watch the browser display
    > ' the exception below.
    > #END IF
    > throw new exception("Try to get past this!")
    > End Sub
    > </script>
    > <body>
    > <form id="Form1" method="post" runat="server">
    > <asp:Button id="Button1" runat="server" Text="Button"
    > OnClick="Button1_Click"></asp:Button>
    > </form>
    > </body>
    > </HTML>
    > <!-- END CODE -->
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    John Saunders Guest

  9. #8

    Default Re: Stop Debugging doesn't stop in ASP.NET

    >does the same problem happen if you don't use STOP, but
    >instead set a breakpoint in the debugger?
    Yes. Using a breakpoint was what initially brought this to my
    attention. I added the STOP statement to emphasize that the break in
    code had to happen *INSIDE* the event handler. If the breakpoint is set
    on the event handler declaration (Public sub Button1_Click (byval...)
    and you don't actually step into the method, but stop the project
    debugging before the event handler code, the problem is not exhibited.

    As posted earlier, it seems like once you step into the event handler,
    Visual Studio is committed to completing the event code.

    BTW, I am using VS 2002, and in the Processes dialog box (Debug |
    Processes) when debugging is stopped, I detach from aspnet_wp.exe and
    terminate iexplore.exe (both the default settings). I tried setting the
    aspnet_wp.exe process to terminate when debugging is stopped, but it did
    not affect the behavior I was examining. Also, this behavior does not
    occur in Windows forms and *IS* reproducible in C# ASP.NET projects.
    However, it is *much* harder to see the exception thrown in the C#
    project. I initially doubted it was happening, but the database access
    proved it.

    I have included both the db access and the throw exception C# code
    below.

    MATT

    C# Exception Only code below:
    <!-- BEGIN CODE -->
    <HTML>
    <script language="C#" runat="server">

    private void Page_Load(object sender, System.EventArgs e)
    {}
    private void Button1_Click(object sender, System.EventArgs e)
    {
    throw new System.Exception("CSharp Get past this!");
    }

    </script>
    <body>
    <form id="Form1" method="post" runat="server">
    <asp:Button id="Button1" runat="server" Text="Button"
    OnClick="Button1_Click"></asp:Button>
    </form>
    </body>
    </HTML>
    <!-- END CODE -->

    C# Database Access code below:
    <!-- BEGIN CODE -->
    <HTML>
    <script language="C#" runat="server">

    private void Page_Load(object sender, System.EventArgs e)
    {}
    private void Button1_Click(object sender, System.EventArgs e)
    {

    System.Data.SqlClient.SqlCommand oCMD = new
    System.Data.SqlClient.SqlCommand("INSERT INTO Categories(CategoryName)
    VALUES('TestC#')");
    oCMD.Connection = new System.Data.SqlClient.SqlConnection("network
    address=localhost; initial catalog=Northwind; integrated
    security=sspi;");
    oCMD.Connection.Open();
    oCMD.CommandType= System.Data.CommandType.Text;
    oCMD.ExecuteNonQuery();
    oCMD.Connection.Close();
    }

    </script>
    <body>
    <form id="Form1" method="post" runat="server">
    <asp:Button id="Button1" runat="server" Text="Button"
    OnClick="Button1_Click"></asp:Button>
    </form>
    </body>
    </HTML>
    <!-- END CODE -->

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Matt Theule Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139