populating Access table field with charater variable
-
I am an oldy trying out some stuff with VB.net - Access coding. My code is almost complete; however, I am having an error populating a charater field. There are five fields in the table seasonNo [integer], sYear [integer], seasObs [double], seasSim [double], and season [char]. In the season field I want to write season of the year. However, with the code below if I replace 1 (last field in cmd line) with sea(im) or eg. "winter", the command gives error. There is no error if it is 1. Any help to remove the error will be greatly appreciated. Dim sea() As String = {"Winter", "Spring", "Summar", "Fall"} For ir = 0 To ty - 1 imYear = minYear + ir For im = 1 To 4 cmd = "insert into seasonSummary VALUES (" & im & " , " & imYear " , " seasObs(im, ir) & " , " & seasSim(im, ir) & " , " & 1 & ")" dbCmd = New OleDbCommand(cmd, myConnection) dbCmd.ExecuteScalar() Next Next
-
I am an oldy trying out some stuff with VB.net - Access coding. My code is almost complete; however, I am having an error populating a charater field. There are five fields in the table seasonNo [integer], sYear [integer], seasObs [double], seasSim [double], and season [char]. In the season field I want to write season of the year. However, with the code below if I replace 1 (last field in cmd line) with sea(im) or eg. "winter", the command gives error. There is no error if it is 1. Any help to remove the error will be greatly appreciated. Dim sea() As String = {"Winter", "Spring", "Summar", "Fall"} For ir = 0 To ty - 1 imYear = minYear + ir For im = 1 To 4 cmd = "insert into seasonSummary VALUES (" & im & " , " & imYear " , " seasObs(im, ir) & " , " & seasSim(im, ir) & " , " & 1 & ")" dbCmd = New OleDbCommand(cmd, myConnection) dbCmd.ExecuteScalar() Next Next
What's the structure of the seasonSummary table? What's the error message you get?