-
Apr 27th, 2012, 02:10 PM
#1
Thread Starter
Junior Member
auto increment number(in a textbox) in vb.net
Hi,
I want to create auto increment number in vb.net like : -
01, 02, 03, 04 etc.. so it is in order.
I am using VB NET 2008 EXPRESS connection OleDb to MS access
I want to do the auto increment for my textbox MemberID
I have tried multiple ways and had no luck such as : -
If txtMemberID.Text = "" Then
txtMemberID.Text = 1
Else
txtMemberID.Text = txtMemberID.Text + 1
End If
'Dim include As Integer
'Integer.TryParse(txtMemberID.Text, include)
'txtMemberID.Text = (Maxrows + 1)
Connect.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Users\Laura\Desktop\VB NEW BACKUPS\Back Up 19.04.12 1\VB Assignment\Members Database\Members.mdb"
Connect.Open()
Try
cmd = New OleDbCommand("select * FROM tblMembers ", Connect)
Dim dr As OleDbDataReader = cmd.ExecuteReader
If dr.Read Then
txtMemberID.Text = dr.Item(0)
Else
txtMemberID.Text = "27"
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
I want to write the code not use the autonumber in Access as my lecturer does not want me to do it this way
Any suggestions please really am struggling with this one.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|