小议中的自动增量列
来源:互联网 发布:Linux deploy vnc 编辑:程序博客网 时间:2024/06/06 15:03
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
ADO中通过DataColumn的3个属性来支持自动增量列:AutoIncrement,AutoIncrementSeed,AutoIncrementStep。只要将DataColumn的AutoIncrement设置为True即可以为DataTable的新行生成自动增量值。看个例子:
DataSet ds=new Dataset();
DataTable dt=ds.Tables.Add("Orders");
DataColumn col=dt.Columns.Add("OrderID",typeof(int));
col.AutoIncrement=true;
col.AutoIncrementSeed=-1;
col.AutoIncrementStep=-1;
col.ReadOnly=true;
上面OrderID列被设为自动增量,注意后面接下来两句,其值都被设为-1,其中有一定的原因。 AutoIncrementSeed和AutoIncrementStep控制着如何生成新值。当遇到空表时,ADO.NET会将存储在AutoIncrementSeed中的值赋给第一行自动增量列,接着AutoIncrementStep生成后续的自动增量值。
原因:ADO.NET中生成的自动增量值仅仅是一个占位符,在中会生成真正的新值,显示出来的仅仅是未提交给数据库的新行自动增量值,数据库可能会根据生成的值来生成不同的值。AutoIncrementSeed和AutoIncrementStep都设为-1,可以确保生成的占位符值不会出现在数据库。
所以在使用AutoIncrement的时候应将AutoIncrementSeed和AutoIncrementStep都设为-1。
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
ADO中通过DataColumn的3个属性来支持自动增量列:AutoIncrement,AutoIncrementSeed,AutoIncrementStep。只要将DataColumn的AutoIncrement设置为True即可以为DataTable的新行生成自动增量值。看个例子:
DataSet ds=new Dataset();
DataTable dt=ds.Tables.Add("Orders");
DataColumn col=dt.Columns.Add("OrderID",typeof(int));
col.AutoIncrement=true;
col.AutoIncrementSeed=-1;
col.AutoIncrementStep=-1;
col.ReadOnly=true;
上面OrderID列被设为自动增量,注意后面接下来两句,其值都被设为-1,其中有一定的原因。 AutoIncrementSeed和AutoIncrementStep控制着如何生成新值。当遇到空表时,ADO.NET会将存储在AutoIncrementSeed中的值赋给第一行自动增量列,接着AutoIncrementStep生成后续的自动增量值。
原因:ADO.NET中生成的自动增量值仅仅是一个占位符,在中会生成真正的新值,显示出来的仅仅是未提交给数据库的新行自动增量值,数据库可能会根据生成的值来生成不同的值。AutoIncrementSeed和AutoIncrementStep都设为-1,可以确保生成的占位符值不会出现在数据库。
所以在使用AutoIncrement的时候应将AutoIncrementSeed和AutoIncrementStep都设为-1。
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 小议中的自动增量列
- 小议ADO.NET中的自动增量列
- datagrid中的自动增长列
- MySQL中的INSERT查询后获取自动增量值
- python中的__name__小议
- Oracle:自动增量解决方法
- 小议jsp中的cookie对象。
- 小议C#中的可空值类型
- 搜索中的剪枝算法小议
- 小议Linux中的僵死进程
- C++中的增量运算
- sqoop中的增量更新
- 小议SQL_Server主键和自动编号问题
- solr配置自动增量更新
- solr配置自动增量更新
- postgresql 的自动增量字段
- solr配置自动增量更新
- vb.net中自动调整datagrid中的列宽
- 重量级Ingres正式开源
- Timeoutexpired.Thetimeoutperiodelapsedpriortocompletionoftheoperationortheserver
- JavaScript中字符串相等比较另类方法
- 浅谈DataSet
- 5月计划
- 小议中的自动增量列
- 用“位”来存储、修改用户权限的方法
- 金额合计求值问题
- 我的adsense优化经验
- javascript(js)浮点数字精度问题的一个解决办法。
- 使用轻松操纵(二)
- 大力的先入先出的库存物品,按批次出货的问题的一个解法。
- 使用轻松操纵
- 有趣的sql(4)-关于注释的,续"有趣的sql(1)"