please check my code: it use to generate number in date format my problem is that it doesnt show any output in the textbox nor in the database
the last num in my database is 2012010001
Dim i As Integer
Dim strSQL As String
Dim strMonth As String
Dim strYear As String
Dim strTheID As String
Dim today As Date
Dim strNewID As String = ""
Dim cmd As SqlCommand
Dim myreader As SqlDataReader
today = Now
strMonth = Format(today, "MM")
strYear = Format(today, "yy")
strTheID = strMonth & strYear
strSQL = "SELECT clearanceno FROM app_information WHERE LEFT(clearanceno,4)='"
strSQL = strSQL & strTheID & "' ORDER BY clearanceno DESC;"
cmd = New SqlCommand(strSQL, Con)
myreader = cmd.ExecuteReader
If myreader.HasRows Then
myreader.Read()
strSQL = myreader.Item("clearanceno")
strSQL = Mid(strSQL, 5)
i = CInt(strSQL) + 1
Select Case i
Case i > 999
strNewID = strTheID & i.ToString
Case i > 99
strNewID = strTheID & "0" & i.ToString
Case i > 9
strNewID = strTheID & "00" & i.ToString
Case Else
strNewID = strTheID & "000" & i.ToString
End Select
End If
myreader.Close()
strClearID = strNewID
txtClearanceNo.Text = strNewID
strClearID = ""