My program has an online and offline mode.
- Online it connects to a SQL Server instance using the C#
SqlCommand
classes. - Offline it connects to a local
.SDF
file using the C#SqlCeCommand
classes.
Now I want to do the following which works when in online mode
GetSqlCommand("insert into my_table (col1) values (@c1); SELECT SCOPE_IDENTITY()", conn))
So I insert a record a get back the ID of that new record with SELECT SCOPE_IDENTITY()
.
But when in offline mode using SQL Server CE, it throws an error. Is there a way to get back ID from the insert with SQL Server CE without running a separate query?