Hello there.. I have a problem with "Conversion from string "" to type integer is not valid".
I put this code into form load. All datatype in my database is Varchar(100).
Why the error keeps pop up? Thank you...
I put this code into form load. All datatype in my database is Varchar(100).
VB.NET:
Private Sub PopulatePekerjaList()
Dim cnSQL As SqlConnection
Dim cmSQL As SqlCommand
Dim drSQL As SqlDataReader
Dim strSQL As String
Dim objListItem As ListPekerja
Try
strSQL = "SELECT employeeName, emel FROM employee"
cnSQL = New SqlConnection(ConnectionString)
cnSQL.Open()
cmSQL = New SqlCommand(strSQL, cnSQL)
drSQL = cmSQL.ExecuteReader()
lstPekerja.Items.Clear()
Do While drSQL.Read()
objListItem = New ListPekerja(drSQL.Item("employeename").ToString(), _
CStr(drSQL.Item("emel")))
lstPekerja.Items.Add(objListItem)
Loop
If lstPekerja.Items.Count > 0 Then
lstPekerja.SetSelected(0, True)
End If
' Close and Clean up objects
drSQL.Close()
cnSQL.Close()
cmSQL.Dispose()
cnSQL.Dispose()
Catch e As SqlException
MsgBox(e.Message, MsgBoxStyle.Critical, "SQL Error")
Catch e As Exception
MsgBox(e.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub
Why the error keeps pop up? Thank you...
Last edited: