hi..... i want to show data i datagridview...
This is my function codes :
Public Function AutoNumber() As String
Dim cnn As New SqlConnection(StrConn)
Dim cmmd As New SqlCommand
Dim dreader As SqlDataReader
Dim KODE As String
Dim TAMPUNG As String
Dim KONTER As String
Dim SQL As String
cnn.Open()
SQL = "SELECT * FROM Seleksi ORDER BY Kd_Seleksi DESC"
cmmd = New SqlCommand(SQL, cnn)
dreader = cmmd.ExecuteReader
If dreader.Read = True Then
TAMPUNG = Right(dreader.Item("Kd_Seleksi"), 3)
KONTER = CInt(TAMPUNG) + 1
KODE = "HS" & Mid("000", 1, 3 - KONTER.Length) & KONTER
Else
KODE = "HS001"
End If
cnn.Close()
Return KODE
End Function
something's wrong... my autonumber in kd_seleksi is not working, i know why, because there is no Kd_Seleksi in table daftar, and the kd_Seleksi is come from autonumber function, so how to make it work...???
would you help me with this????