I am getting an error:
OleDbCommand.Prepare method requires all parameters to have an explicitly set type.
on the last line of the code below. I have seen things saying you have to set the datatype of each parameter but how can i do that when it being generated by the command builder?
I have seen people say they dont like using autogenerated queries, is this a bad way to go about doing what I am trying to do?
Dim checkDock As New OleDbCommand("SELECT Instance, DocketNumber, FormID, FieldName, Occurrence, FieldValue FROM fielddata WHERE docketnumber = @dock AND formid = @formid " & _
"AND instance = @inst1")
checkDock.Connection = New OleDbConnection("Provider=" & My.Settings.Provider & ";" & "Data Source=" & My.Settings.DataSource1)
'create and execute the command to retrieve the saved data for the original instance
checkDock.Parameters.AddWithValue("@dock", dock)
checkDock.Parameters.AddWithValue("@formid", formid)
checkDock.Parameters.AddWithValue("@inst1", inst1)
Dim da As New OleDbDataAdapter(checkDock)
Dim dSet As New DataSet("copySet")
da.Fill(dSet)
'create a command builder to put the new entries in the database
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim rowList As New ArrayList()
For Each r As DataRow In dSet.Tables(0).Rows
Dim dRow As DataRow = dSet.Tables(0).NewRow
dRow.Item("Docketnumber") = dock2
dRow.Item("Formid") = formid
dRow.Item("fieldname") = r.Item("fieldname")
dRow.Item("occurrence") = r.Item("occurrence")
dRow.Item("fieldvalue") = r.Item("fieldvalue")
dRow.Item("Instance") = inst2
rowList.Add(dRow)
Next
For Each a As DataRow In rowList
dSet.Tables(0).Rows.Add(a)
Next
da.Update(dSet)