Bug #56253 myodbc5.dll crashed when the .Update method is used with more than 2 fields
Submitted: 25 Aug 2010 13:30 Modified: 9 Aug 2022 11:00
Reporter: Andrei Iancu Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.1.8 OS:Windows (Windows XP SP3)
Assigned to: Bogdan Degtyariov CPU Architecture:Any
Tags: connector odbc crash vb6 visual basic .update method strings

[25 Aug 2010 13:30] Andrei Iancu
Description:
For an unknown reason, myodbc5.dll crashes when i try to update some fields with the update method from ADO, using the ODBC Driver. This does not happen always, though. If i have fields that are integers or floats, the data is updated. If i have fields that are string, .update also works. BUT, if i have a mix of strings and integers, it crashes and crashed vb6 ide along with it. Source code is available and database structure too.

How to repeat:
Create a schema witha table (let's say Products) containing some some INTEGER columns, some FLOAT columns,  some TEXT columns. 

Let's name the database 'test_db'.

After that, let's connect from vb6 through an ODBC driver 

Driver={mySQL ODBC 5.1 Driver};Server=192.168.1.1;Port=3306;Option=3;Database=test_db;Uid=root;Pwd=some_root_password;

Now, let's create a new entry in the schema....

ComandaSQL = "SELECT * FROM Products;"
    
vDBRecordset.Open (ComandaSQL), vDBConnection, adOpenDynamic, adLockOptimistic
 With vDBRecordset
     .AddNew
       !idproduct = 10             ' integer
       !priceeuro = 40             ' float
       !vatproc = 24               ' float
       !code = "testcode123"       ' string
       !model = "testmodel123"     ' string
       !comments = "200 dpi mode"  ' string
    .Update
 End With
If vDBRecordset.state = 1 Then vDBRecordset.Close

Everything works until i hit the .Update line... then it crashes.

Suggested fix:
It seems to me there's a problem with the 'float' data type, somewhere. It is not handled correctly. VB6 does not have float, is has Double and Currency.
The connector should be able to convert other data types to float....
[25 Aug 2010 13:31] Andrei Iancu
crash of screenshot

Attachment: untitled.jpg (image/pjpeg, text), 200.02 KiB.

[25 Aug 2010 16:42] Andrei Iancu
finally, found the fix for this, after maaaaaany hours spent on the net, thought i might share it with you :

you have to set the following property before you use the OPEN method of the connection class.... 

     vDBConnection.CursorLocation = adUseClient

then, you can use open....

     vDBConnection.Open (vConnectionString), , , 0

and presto ! it works flawlessly !
[25 Aug 2010 20:06] Lawrenty Novitsky
That is very good that there is workaround, but the bug still exists probably. Did I understand correctly that your application didn't crash with previous driver version - 5.1.6, and appeared with the update to version 5.1.7?
[25 Aug 2010 20:29] Andrei Iancu
unfortunately, the the app. used to crash in 5.1.6 too.... i downloaded the more recent 5.1.7 and the problem was still there...
[11 Oct 2011 9:26] Bogdan Degtyariov
With the versions 5.1.8/5.1.9 Access doesn't crash anymore, but it inserts 0 for idproduct instead of 10 as indicated in the test case.
[11 Oct 2011 9:29] Bogdan Degtyariov
CREATE TABLE `bug56253` (
`idproduct`  int NULL ,
`priceeuro`  float NULL ,
`vatproc`  float NULL ,
`code`  varchar(32) NULL ,
`model`  varchar(64) NULL ,
`comments`  text NULL ,
PRIMARY KEY (`idproduct`));

' VB Test case
Sub bug56253()
    Dim conn As ADODB.Connection
    Set conn = New ADODB.Connection
    
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    
    conn.Open "DSN=test", "*******", "********", 0
    rs.Open "SELECT * FROM bug56253", conn, adOpenDynamic, adLockOptimistic
    With rs
         .AddNew
           !idproduct = 10             ' integer
           !priceeuro = 40             ' float
           !vatproc = 24               ' float
           !code = "testcode123"       ' string
           !model = "testmodel123"     ' string
           !comments = "200 dpi mode"  ' string
        .Update
    End With
End Sub
[11 Oct 2011 9:30] Bogdan Degtyariov
Bug #62365 is marked as a duplicate of this one.
The current report has much simpler test case.
[9 Aug 2022 11:00] Bogdan Degtyariov
Posted by developer:
 
This bug is no longer repeatable with the current line of Connector/ODBC 8.0.