5 Replies - 1086 Views - Last Post: 21 October 2012 - 11:15 AM Rate Topic: -----

#1 pratik65  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 10-September 12

i want to initialize my id column in my database from 0 when dgv is..

Posted 30 September 2012 - 10:51 AM

i am trying to initialize my ID column of my LOGIN Table from 1 again when i enter a first data in the DataGridView but i am getting one number ahead of the previous ID no which was deleted

 
 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


        [b]If DataGridView1.Item(0, 0).Value = vbEmpty Then
            DataGridView1.Item(0, 0).Value=initialize
[/b]
        
End If




Is This A Good Question/Topic? 0
  • +

Replies To: i want to initialize my id column in my database from 0 when dgv is..

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1031
  • View blog
  • Posts: 4,013
  • Joined: 02-July 08

Re: i want to initialize my id column in my database from 0 when dgv is..

Posted 30 September 2012 - 11:23 AM

This will give the last id given to this field so add 1 and you now have a new id even when there are missing numbers in your id column from deletions.

Select Max({idcolumn}) From LoginTable
Was This Post Helpful? 0
  • +
  • -

#3 pratik65  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 10-September 12

Re: i want to initialize my id column in my database from 0 when dgv is..

Posted 20 October 2012 - 11:24 PM

i didnt get ur answer cn u please elaborate your self

i am new to vb.net so i didnt understood ur code

how do i use your code in my project ..?
Was This Post Helpful? 0
  • +
  • -

#4 CharlieMay  Icon User is online

  • This space intentionally left blank
  • member icon

Reputation: 1534
  • View blog
  • Posts: 4,933
  • Joined: 25-September 09

Re: i want to initialize my id column in my database from 0 when dgv is..

Posted 21 October 2012 - 04:48 AM

You didn't specify the database you're using:

Here is information forSQL Server

Here is information for MS Access

Here is information for MySQL
Was This Post Helpful? 0
  • +
  • -

#5 pratik65  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 10-September 12

Re: i want to initialize my id column in my database from 0 when dgv is..

Posted 21 October 2012 - 11:04 AM

im using SQl Express that comes withvb.net 2010
and i am not getting the id coloumn initialised from 1 whenevr i empty the datgridview of my Tables of project
Was This Post Helpful? 0
  • +
  • -

#6 pratik65  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 10-September 12

Re: i want to initialize my id column in my database from 0 when dgv is..

Posted 21 October 2012 - 11:15 AM

i didnt understood to use the query that rest the id column
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1