0

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.i am
using sql 2005 and vb.net
1. Private Sub
DataGridView1_
CellContentClick
(ByVal sender As
System.Object,
ByVal e As
System.Windows.
Forms.DataGridVi
ewCellEventArgs)
Handles
DataGridView1.
CellContentClick
2. Dim i As
Integer
3. i =
DataGridView1.
CurrentRow.Index
4. TxtId.Text
= DataGridView1.
Item(0, i).Value
5.
TxtUsername.
Text =
DataGridView1.
Item(1, i).Value
6.
TxtPassword.
Text =
DataGridView1.
Item(2, i).Value
7. If
DataGridView1.
Item(0, 0).Value
= vbEmpty Then
8.
DataGridView1.
Item(0, 0)
.Value=initialize 9. 10. End If

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Begginnerdev
0

First of all: Whoa! That formatting was terrible.

Second of all: Try something like this:

Dim cmd as New OleDbCommand("DBCC CHECKIDENT (YOUR_TABLE_NAME_HERE, RESEED, 0)",YOUR_CONNECTION_HERE)
cmd.ExecuteNonQuery

'This will reseed the table and set the identity back to 0
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.