如何使用Sql compact& amp;启用自动递增C# [英] How to enable auto-increment with Sql compact & C#

查看:108
本文介绍了如何使用Sql compact& amp;启用自动递增C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#2010 Express.

I'm using C# 2010 Express.

我创建了一个SQL Server CE数据库文件(.sdf),然后使用数据库资源管理器创建了信息表和ID,名称,城市列.我要保存名称,城市用户将写入表格.在数据库浏览器和属性"窗口中禁用了自动增量选项.当我将某些内容保存到该数据库时,我必须手动更改ID,如何使ID列自动启用?

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有一种简单的方法:

There is a simple way for SQL CE:

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

这篇关于如何使用Sql compact& amp;启用自动递增C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆