User-1578974752 posted
I am using vb.net(vs 2017) and sql 2017
Incident table is having Incidentnumber as primary key and datatype Bigint with auto increment 1.So the first number will be 1...then 2..
Actually in vb.net program I want this Incidentnumber to concatenated with SING .The first number must be 0001 then 0002....2000,2001 like that .Format will be
SING0001,SING0002..........SING0100....SING1000..SING1001,SING1002 etc
So In vb.net my code is as follows
Try
cmd = New SqlCommand
cmd.Connection = con
cmd.CommandText = "Insert into IncidentMaster(Name) values ('" + Name.Text + "')"
cmd.ExecuteNonQuery()
cmd.Dispose()
cmd.CommandText = "SELECT TOP(1) Incidentnumber FROM IncidentMaster ORDER BY 1 DESC"
drd = cmd.ExecuteReader
If drd.HasRows = True Then
drd.Read()
incidentnumber.Text = drd.Item("Incidentnumber")
End If
cmd.Dispose()
drd.Close()
Catch ex As Exception
Finally
cmd.Dispose()
End Try
I am confused at below code .I want to add 'SING' infront of the incidentnumber.Text value.value of incident number in sql databse will be 1. But I want the answer to be SING0001 and now it coming SING1.
newnumber.Text = "SING" & incidentnumber.Text
Thanks in advance