从1开始重新初始化登录表的id列 [英] intializing id column of login table again from 1 whe it is empty
本文介绍了从1开始重新初始化登录表的id列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我清空数据库时,我尝试从1中初始化我的id列agin,但是它不起作用请尽快给我一些建议...我的代码是gien下面的:
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object,ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)Handles DataGridView1.CellContentClick
Dim i As Integer
i = DataGridView1.CurrentRow.Index
TxtId .Text = DataGridView1.Item(0,i).Value
TxtUsername.Text = DataGridView1.Item(1,i).Value
TxtPassword.Text = DataGridView1.Item(2,i).Value
如果DataGridView1.Item(0,0).Value = vbEmpty那么
DataGridView1.Item(0,0).Value = initialize
结束If
i也尝试了这段代码,但没有得到任何东西:
DBCC CHECKIDENT(订单,RESEED, 0 )
解决方案
< blockquote>假设你的id是一个标识列,它也不错: http://technet.microsoft.com /en-us/library/ms176057.aspx [ ^ ]
所以SQL:
DBCC CHECKIDENT(MyTableName,RESEED, 0 ) WITH NO_INFOMSGS
将意味着下一个创建的记录的值为1.
I tried to intialize my id column agin from 1 when i empty the database but it is not working please suggest me something asap...my code is gien below:
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick Dim i As Integer i = DataGridView1.CurrentRow.Index TxtId.Text = DataGridView1.Item(0, i).Value TxtUsername.Text = DataGridView1.Item(1, i).Value TxtPassword.Text = DataGridView1.Item(2, i).Value If DataGridView1.Item(0, 0).Value = vbEmpty Then DataGridView1.Item(0, 0).Value=initialize End If
i tried this code too but didnt get any thing:
DBCC CHECKIDENT (orders, RESEED, 0)
解决方案
Assuming your id is an identity column, it's not too bad: http://technet.microsoft.com/en-us/library/ms176057.aspx[^]
So the SQL:
DBCC CHECKIDENT (MyTableName, RESEED, 0) WITH NO_INFOMSGSWill mean the next created record will have a value of 1.
这篇关于从1开始重新初始化登录表的id列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文