I not sure if I should create a new post on this but here goes.
I am attempting to write data to a recordset as per the MSDN site.
recordset.AddNew FieldList, Values
recordset: A Recordset object. FieldList: Optional. A single name, or an array of names or ordinal positions of the fields in the new record.
Values
Optional. A single value, or an array of values for the fields in the new record. If Fieldlist is an array, Values must also be an array with the same number of members; otherwise, an error occurs. The order of field names must match the order of field values in each array.
However I get an error. COMException was unhandled by user code.{"Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."
any ideas or suggestions.
Private Sub Addrecord()
Dim catDB As ADOX.Catalog
Dim strDBPath As String = "c:\newdata.mdb"
Dim strTbl As String = "Annotation"
catDB = New ADOX.Catalog
' Open the catalog.
Dim cnn As New ADODB.Connection
cnn.Open("Provider='Microsoft.Jet.OLEDB.4.0';" & _
"Data Source= '" & strDBPath & "';")
catDB.ActiveConnection = cnn
Dim rs = New ADODB.Recordset
rs.Open(strTbl, cnn, CursorTypeEnum.adOpenKeyset, LockTypeEnum.adLockOptimistic) 'adOpenKeyset, adLockOptimistic, adCmdTable)
Dim fieldsArray(6) As String
fieldsArray(0) = "ADMAPKEY"
fieldsArray(1) = "LotKey"
fieldsArray(2) = "X1"
fieldsArray(3) = "Y1"
fieldsArray(4) = "TEXT_ANGLE"
fieldsArray(5) = "TEXT_SIZE"
fieldsArray(6) = "TEXTSTRING"
Dim values(6) As Object
values(0) = "Hello"
values(1) = 1111
values(2) = 2222
values(3) = 33333
values(4) = 4444
values(5) = 5555
values(6) = "TEST"
rs.AddNew(fieldsArray, values)
'rs.AddNew()
'rs.Fields.Item("ADMAPKEY").Value = "Hello"
'rs.Fields.Item("LotKey").Value = 222
'rs.Fields.Item("X1").Value = 123
'rs.Fields.Item("Y1").Value = 456
'rs.Fields.Item("TEXT_ANGLE").Value = 789
'rs.Fields.Item("TEXT_SIZE").Value = 234
'rs.Fields.Item("TEXTSTRING").Value = "Hello"
'rs.AddNew()
rs.Update()
rs.Close()
rs = Nothing
End Sub