By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,903 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,903 IT Pros & Developers. It's quick & easy.

Autogenerate serial number in textbox

P: 4
hi
i want to generate serial number in text box when i click on button.so please help me
Apr 18 '14 #1
Share this Question
Share on Google+
2 Replies


P: 1
if use random function or if use database then fire to select query & get last record id or number , add it one and then display textbox.
Apr 18 '14 #2

P: 4
thanks for the reply.
i have the following code that generate serial number,but problem is that if i save 4 serial numbers and i delete serial number 3 and when i click to generate new serial number then its show 5 and 3 is missing.do you have any solution for this?


Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim dr As OleDbDataReader
  3.         Dim a As Integer
  4.         If Not cn.State = ConnectionState.Open Then
  5.             cn.Open()
  6.         End If
  7.         sqlqry = "select srno from Records"
  8.         cmd = New OleDbCommand(sqlqry, cn)
  9.         dr = cmd.ExecuteReader
  10.         While dr.Read
  11.             a = dr(0)
  12.         End While
  13.  
  14.         Dim i As Integer
  15.  
  16.         If Integer.TryParse(CStr(CDbl(a) + 1), i) Then
  17.             TextBox1.Text = i.ToString
  18.         End If
  19.  
  20.  
Apr 20 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.