How to enable auto-increment with Sql compact & C#

情到浓时终转凉″ 提交于 2019-12-06 15:06:04

问题


I'm using C# 2010 Express.

I have created a SQL Server CE database file (.sdf) then created Information table and ID, Name, City columns with Database Explorer. I want to save names and city user will write to the form. The auto-increment option is disabled in Database explorer and Properties windows. When I'm saving something to that database i must change the ID manually, how can I make ID column auto-increment enabled?


回答1:


There is a simple way for SQL CE:

ALTER TABLE TableName ALTER COLUMN ColumnName IDENTITY (/*seed*/1, /*increment*/1)


来源:https://stackoverflow.com/questions/5052922/how-to-enable-auto-increment-with-sql-compact-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!