再次将ID列初始化1 [英] initializing id column again by 1

查看:49
本文介绍了再次将ID列初始化1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个登录表,并通过datagridview在其中填充记录,但是当我删除所有记录并使表为空时,然后当我将记录放入登录表时,它比上次删除的记录要早1 .i希望它为空时再次从1开始登录表的id列

i made a login table and i am filling records in it through my datagridview but when i delete all the records and make the table empty and then when i put the record in the login table it takes 1 no ahead of last deleted record .i want it to start the id column of login table from 1 again whent it is empty

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<pre lang="vb">

推荐答案

如果您使用的是SQL Server,请使用DBCC检查 [ ^ ].
If you are using SQL Server, use DBCC CHECKIDENT[^].


如果您删除了所有记录,则会以编程方式截断表
truncate your table programmaticly if your had deleted all your records


这篇关于再次将ID列初始化1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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