Description:
Attempting to update a recordset containing a mysql Decimal data type (ADO type adNumeric) results in the following error:
[MySQL][MyODBC 5.00.12] unknown C data type 2 -2147467259
NOTE: This does not occur with MyODBC 3.51.14
How to repeat:
SETUP:
mysql> CREATE TABLE ado_test (C1 INT PRIMARY KEY, C2 DECIMAL(10));
mysql> INSERT INTO ado_test VALUES (1, 101), (2, 202);
VB code:
Private Sub Test()
On Error GoTo EH
Dim strSQL, strConn As String
Dim connection1 As ADODB.Connection
Dim recset1 As ADODB.Recordset
Dim fld As Field
Set connection1 = New ADODB.Connection
Set recset1 = New ADODB.Recordset
strSQL = "SELECT * FROM ado_test"
strConn = "DRIVER={MySQL Connector/ODBC v5};" & _
"SERVER=localhost;DATABASE=ado" & _
";UID=root;PWD=mypass;OPTION=3;"
'open connection
connection1.ConnectionString = strConn
connection1.CursorLocation = adUseServer
connection1.Open
recset1.Open strSQL, connection1, adOpenForwardOnly, _
adLockOptimistic, adCmdText
recset1.MoveFirst
For Each fld In recset1.Fields
If fld.Type = adNumeric Then
fld.Value = fld.Value + 1
recset1.Update
End If
Next
Exit Sub
EH:
Debug.Print Err.Description & " " & Err.Number & vbNewLine
End Sub
Description: Attempting to update a recordset containing a mysql Decimal data type (ADO type adNumeric) results in the following error: [MySQL][MyODBC 5.00.12] unknown C data type 2 -2147467259 NOTE: This does not occur with MyODBC 3.51.14 How to repeat: SETUP: mysql> CREATE TABLE ado_test (C1 INT PRIMARY KEY, C2 DECIMAL(10)); mysql> INSERT INTO ado_test VALUES (1, 101), (2, 202); VB code: Private Sub Test() On Error GoTo EH Dim strSQL, strConn As String Dim connection1 As ADODB.Connection Dim recset1 As ADODB.Recordset Dim fld As Field Set connection1 = New ADODB.Connection Set recset1 = New ADODB.Recordset strSQL = "SELECT * FROM ado_test" strConn = "DRIVER={MySQL Connector/ODBC v5};" & _ "SERVER=localhost;DATABASE=ado" & _ ";UID=root;PWD=mypass;OPTION=3;" 'open connection connection1.ConnectionString = strConn connection1.CursorLocation = adUseServer connection1.Open recset1.Open strSQL, connection1, adOpenForwardOnly, _ adLockOptimistic, adCmdText recset1.MoveFirst For Each fld In recset1.Fields If fld.Type = adNumeric Then fld.Value = fld.Value + 1 recset1.Update End If Next Exit Sub EH: Debug.Print Err.Description & " " & Err.Number & vbNewLine End Sub