Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how can i fetch auto-incremented number from SQL to vb.net window from when form loads to a label i have column name caseno which is auto-incremented and when i open form it should show last caseno + 1 in my label i used the below code in form load

What I have tried:

Dim Nextid As String

Dim connection As New SqlConnection("server= madhuresh-pc; database= madhu; integrated security= true")
connection.Open()

Dim cmd As New SqlCommand("SELECT MAX(caseno+1) As 'NextId' FROM case1", connection)
Nextid = cmd.ExecuteScalar()
Label1.Text = Nextid
connection.Close()
Posted
Updated 22-Sep-17 8:03am
Comments
Richard Deeming 22-Sep-17 12:09pm    
REPOST
You have already asked this. The answer has not changed since Wednesday.
https://www.codeproject.com/Questions/1207091/Fetch-auto-incriment-number-from-SQL-server[^]

1 solution

I already told you what to do: this is not a good idea at all, you will cause yourself huge problems down the line.
Fetch auto incriment number from SQL server[^]
 
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