Dear Friends,
Good Day,
I am facing an issue in one of the functions the code is given below if someone can help on this actually this function is supposed to check the work ordewr number if it's nulll then it is suppose to take default value as 4999 and add one everytime, but the function is not taking the default value its is starting from 1 and then next record +1 means 2 like this but it supposed to be like 4999+1 means 5000 next record 5000+1 means 5001 like this. Any help in this regard will be highly appriciated. i am using VB.NET with Oracle Database.
Private Function Auto_no() As Integer
Dim con As New OracleConnection(ConnectionString)
Dim com As OracleCommand = Nothing
Dim retVal As Object
Try
con.Open()
com = New OracleCommand("SELECT MAX(WO_NO) FROM WO GROUP BY WO_NO ORDER BY WO_NO DESC", con)
retVal = com.ExecuteScalar()
If Not IsDBNull(retVal) Then
retVal += 1
Else
retVal = 4999
End If
con.Close()
Catch ex As OracleException
If con.State = ConnectionState.Open Then
con.Close()
End If
retVal = 4999
End Try
Return retVal
End Function