Data Error

liunx

Guest
I am trying to do somthing in windows forms, but get this error when i want to insert data

an unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll

Additional information: Cast from string "//" to type 'Date' is not valid.


I am using comboboes for day,month and year as dropdown


Private Sub btnvoegby_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnvoegby.Click
Dim dateStr As String = lstMonth.SelectedValue & "/" & lstDay.SelectedValue & "/" & lstYear.SelectedValue
Dim dateStr1 As String = lstMonth1.SelectedValue & "/" & lstDay1.SelectedValue & "/" & lstYear1.SelectedValue

rs.Open("Select * from ss", cnConnection, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
rs.AddNew()
rs.Fields("Naam").Value = txtNaam.Text
rs.Fields("Van").Value = txtVan.Text
rs.Fields("Geboorte_datum").Value = dateStr
rs.Fields("Ouderdom").Value = txtouderdom
rs.Fields("Sosiale_Profiel").Value = lstProfiel.SelectedValue
rs.Fields("Aangesluit").Value = dateStr1
rs.Fields("Onderwyser").Value = lstonnie
rs.Fields("Add1").Value = txtadd1
rs.Fields("Add2").Value = txtadd2
rs.Fields("Add3").Value = txtadd3
rs.Fields("Add4").Value = txtadd4
rs.Fields("Tel_H").Value = txttelh
rs.Update()This is saying that lstMonth, lstYear, and lstDay have no value for the selectedValue property. It seems the actual problem is occuring at another place in your application. Trace back your steps and you should find your problem.

Regards.
 
Back
Top