SQL CE insert fails until I view the table

I notice something strange. I am porting an application to work with Sql Server CE 3.5 and find something strange.

What I see is that the insert will not work (violating the primary key constraint) and will continue to fail until I use the Visual Studios Server Explorer and open the table with the Show Data function.

Whether it parameterized SQL

all columns (except the primary key) in my code, or even did "INSERT INTO SecurityUser (UserName) VALUES (" ch00k ")" from the server explorer, this is always a primary key constraint (in this case, the primary key is SecurityUserID and I double checked it is auto increment field) and it always works (and keeps working) after I open the table in visual studio.

Has anyone encountered something similar before? Or is there some extra bit SQL

that I have to run when I create the table to get the primary key to work? The generated tabular code has just been migrated straight from the Sql Server 2005 code and is working without errors.

+1


source to share





All Articles