I have some code from this site CodeProjectLink to convert a datatable to a recordset. This code had been working fine until I changed to .NET 4 (was previously 2), now when I call the following line:
Dim result As New ADODB.Recordset()
result.CursorLocation = ADODB.CursorLocationEnum.adUseClient
Dim resultFields As ADODB.Fields = result.Fields
Dim inColumns As System.Data.DataColumnCollection = inTable.Columns
For Each inColumn As DataColumn In inColumns
' The next line gives the error
resultFields.Append(
inColumn.ColumnName,
TranslateType(inColumn.DataType),
inColumn.MaxLength,
IIf(inColumn.AllowDBNull,
ADODB.FieldAttributeEnum.adFldIsNullable,
ADODB.FieldAttributeEnum.adFldUnspecified),
Nothing)
Next
I get this strange error:
Error: Missing method 'instance void MYDLLNAME ADODB.Fields::Append(string,valuetype ADODB.DataTypeEnum,int32,valuetype ADODB.FieldAttributeEnum,object)' from class 'ADODB.InternalFields'.
I tried changing my line to just:
resultFields.Append(inColumn.ColumnName, TranslateType(inColumn.DataType))
but this gave the same error. The TranslateType function is correctly returning ADODB.DataTypeEnum.adVarChar so this seems valid as well