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

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.