Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if in database column is null how to genrate next auto genrate number i am using this code


VB
Dim cmd As New SqlCommand
      cmd.CommandType = CommandType.Text
      cmd.Connection = myconn
      cmd.CommandText = "select Max(token_no) from billentry"
      myconn.Open()
      Dim a As Integer = cmd.ExecuteScalar
      myconn.Close()
      TextBox1.Text = a + 1
Posted

1 solution

You should handle such an error condition. The way to do that is up to you: you may, for instance, use a default value or prompt a message box to the user.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900