Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Feb 07, 2007 09:43 AM|LINK
When debugging the server-side code of my ASP page, if I stop debugging (via the 'Stop Debugging' option on the debug menu or the equivalent tool-bar button) although this appears to stop the debugging session, it actually executes the subsequent code.
(I am using Visual Studio 2005 SP1 and IE7, running under Windows XP Professional.)
Steps to reproduce the issue:
1. Create a new table in your SQL Server database called 'Table1', containing a varchar(50) column called 'Column1'.
2. Create a new ASP.Net web site (using C#).
3. Add an ASP button control to the 'Default.aspx' page and double-click it to create the event handler.
4. Add a reference to the 'System.Data.SQLClient' namespace.
5. Paste the following routine into the 'Default.aspx.cs' file:
private bool AddRecord()
SqlConnection cnn = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=YourDB;Data Source=(local)");
SqlCommand cmd = new SqlCommand("INSERT INTO Table1 (Column1) VALUES ('This record should not exist')", cnn);
cmd.CommandType = CommandType.Text;
catch (Exception ex)
(You will have to adjust the connection string as appropriate for your database.)
6. Add a call to the 'AddRecord' function into the 'Button1_Click' function like so:
protected void Button1_Click(object sender, EventArgs e)
7. Put a breakpoint anywhere before the line 'cmd.ExecuteNonQuery();'.
8. Run the project in debug and when it hits the breakpoint - stop it.
9. Examine the contents of Table1, it should have a record in it, despite the fact that the SQL insert command should not have been executed.