tags:

views:

61

answers:

3

ASP.NET 2.0, SQL 2005. I have a very basic insert statement. I enter all the data into the app and step through. No errors are rasied in the app or the stored proc. Yet, when I go to check out the table, no record was inserted. Is there some sort of quirk or bug in SQL server I am unaware of? I have tried ExecuteScalar & ExecuteNonQuery.

+2  A: 

You need to commit your transaction.

clownbaby
+4  A: 

Can it be that you open a transaction and never Commit one? Remember that

using(var transaction = connection.BeginTransaction())
{
    // Code
}

does not commit it, but rather rolls back the whole thing. You have to explicitly invoke transaction.Commit().

Anton Gogolev
A: 

I had (have) this problem on a website of mine written in PHP. If you are trying to insert a string are you sure you have escaped all necessary characters? Using a single quote in something like don't, won't, or aren't needs to be escaped!

Reed Debaets
You shouldn't be concatentating strings together to build up a query anyway. Properly parameeterised query won't have this problem.
Paddy