View Single Post
Old 08-06-2004, 06:25 AM   #8 (permalink)
Stompy
Banned from being Banned
 
Location: Donkey
Load up a new asp.net project.

Add a button to the default webform and add the following code to the click event (don't forget to include "using System.Data.SqlClient;" at the top):

Code:
		private void Button1_Click(object sender, System.EventArgs e)
		{
			SqlConnection conn = new SqlConnection("server=127.0.0.1;uid=sa;pwd=mypass;database=Northwind");
			SqlCommand cmd = new SqlCommand("INSERT INTO	dbo.Categories (CategoryName) VALUES (@CategoryName)", conn);
			
			cmd.CommandType = CommandType.Text;

			cmd.Parameters.Add(new SqlParameter("@CategoryName", SqlDbType.NVarChar, 15));
			cmd.Parameters["@CategoryName"].Value = "test";

			conn.Open();
			cmd.ExecuteNonQuery();

			cmd.Dispose();
			conn.Dispose();
		}
Breakpoint the line "cmd.ExecuteNonQuery();"

When the debugger reaches that point, hit stop. Look in your northwind database and you will see a category called "test". Even if you breakpoint on conn.Open(), the category is added.

This does it on all of my development machines (4), so I don't think it's a botched install.

[edit]
I just tried this in a plain old windows forms application and there is no bug, so perhaps it's an error in the asp.net worker process.
__________________
I love lamp.

Last edited by Stompy; 08-06-2004 at 06:32 AM..
Stompy is offline  
 

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