如何创建自动编号 [英] how to create autonumber
本文介绍了如何创建自动编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用c#为数据库创建自动编号功能.仅在c#
How to create autonumber function for a database using c#. Provide the clear code only in c#
推荐答案
中提供清晰的代码,所有您需要做的就是以通常的方式连接到数据库,并创建一个SqlCommand,例如:
All you have to do is connect to your DB in the usual way, and create an SqlCommand such as:
USE [MyDataBaseName]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MyTable](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [nchar](10) NOT NULL,
) ON [PRIMARY]
GO
然后调用ExecuteNonQuery.
P.S.如果您有一点礼貌,可能会找到更好的解决方案.
我们不会为您工作,我们不会为此而获得报酬,而且像您那样粗鲁的傲慢也不会使您走远.
Then call ExecuteNonQuery.
P.S. If you had been a little polite, you might have got a better solution.
We do not work for you, we do not get paid to do this, and rude arrogance like you show will not get you far.
这篇关于如何创建自动编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文