简体   繁体   中英

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

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?

SQL CE有一种简单的方法:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM