Bug #12387 MyODBC causes crash while trying to open a recordset using a SELECT statement
Submitted: 4 Aug 2005 15:33 Modified: 1 Feb 2007 7:18
Reporter: Javier Rodriguez Paiva Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S1 (Critical)
Version:5.0.0-alpha OS:Windows (Win XP Pro SP2)
Assigned to: Jess Balint CPU Architecture:Any

[4 Aug 2005 15:33] Javier Rodriguez Paiva
Description:
I just installed the new ODBC to give it a try. I'm developing in Visual Basic 6.0 SP6 and using ADODB. While trying to open a recordset using a SELECT statement, the system stops to respond for a while, and then it presents the following error message: 

The instruction at "0x10023b26" referenced memory at "'0x10023b2c". The memory could not be "written". 

This kind of error doesn't usually present itself in Visual Basic applications, it usually does when programming in C (so I suspect it's being caused by the ODBC driver).

How to repeat:
Create a sample table in Test database. Open a new visual basic proyect and paste this code.

Dim oConn As ADODB.Connection

Private Sub Form_Load()
    Dim oRS As New ADODB.Recordset
    Dim strSQL As String
    
    Set oConn = New ADODB.Connection

    strSQL = "DRIVER={MySQL Connector/ODBC v5};SERVER=localhost;DATABASE=test;USER=root;PASSWORD=pass;OPTION=3;"
    oConn.CursorLocation = adUseClient
    oConn.Open strSQL
    
    strSQL = "SELECT * FROM T_Juego;"
    oRS.Open strSQL, oConn
    
End Sub

The bug presents at the oRS.Open statement.
[4 Aug 2005 19:36] Luis A S Junior Camargo
I have the same problem, the aplicattion crash at connection to server, but without any information, i use Visual Basic 6 SP6, Windows 2000 SP4 and ODBC 5.0.0 Alpha.
[4 Aug 2005 19:54] Luis A S Junior Camargo
The error occurs in the connection to server, not in the SELECT, this is my example code:

Dim conexao As New ADODB.Connection
Dim strConnectionString As String

strConnectionString = "Driver={MySQL Connector/ODBC
v5};Server=127.0.01;Port=3306;Database=test;UID=test;PWD=test;Option=16427"
conexao.Open strConnectionString           <= CRASHING AT THIS LINE
[5 Aug 2005 7:47] Vasily Kishkin
I've got follow message:
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at ADODB.RecordsetClass.Open(Object Source, Object ActiveConnection, CursorTypeEnum CursorType, LockTypeEnum LockType
, Int32 Options)

Do you mean this error ?
[5 Aug 2005 14:31] Javier Rodriguez Paiva
Nope, the error message I get is:

The instruction at "0x10023b26" referenced memory at "'0x10023b2c". The memory
could not be "written". 

And the whole Visual Basic crashes (it doesn't just crash the proyect in execution). The error occurs when I try to open the recordset (the database connection seems to work ok). I'm using VB 6 (not .NET)
[8 Aug 2005 10:25] Massimiliano Grandi
Well, I'm working with Vb6 + sp6 on windows xp sp2.
The problem occurs when you try to open the recordset, the connection is OK (you can see this using the ODBC Manager in Administrative tools and creating a simple DSN and testing the parameter you have entered).

I.e.:

sql = "SELECT * FROM Orders"
rs.open sql,adoConn ....

The connection string creating the error is wrong in fact the server item you provided is 127.0.01 and not 127.0.0.1 as it should be.
[8 Aug 2005 12:20] Luis A S Junior Camargo
Hi, Massimiliano Grandi,

The IP 127.0.01 (127.0.0.1) is wrong only in this submit, my server is running in other machine and IP, diferent of localhost and 127.0.0.1, the error continue.
[11 Aug 2005 8:50] Vasily Kishkin
My VB does't crash so fatality. But I've got error message. I attached my test case.
[11 Aug 2005 8:51] Vasily Kishkin
Test case

Attachment: 12387.zip (application/x-zip-compressed, text), 5.51 KiB.

[1 Oct 2005 4:24] archer vallesfin
I've got same message:
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.

I hope this have solution or I will revert to an old mysql.

The connection is OK only this happen during query.
[9 Jan 2006 15:20] Gonzalo Teijido
I tested this on Windows 2003 and Windows 2000 Pro SP4 with ASP 3.0 and VB6.

I´ve installed the MySQL 5.0.0 alpha engine in boths PCs, created test databases on both and tried to open the recordset the program through the network and running on both localhosts.

In both cases the ASP code throughts an error in the Recordset Open method. Then VB6 throughts the error that says that the memory can´t be written that many of you mentioned.

I´m using the MySQL ODBC Connector 5.0.0 alpha and the Microsoft ActiveX Data Objects 2.5 Library in VB6.

ASP code:
	Dim con
	Dim rst
	Set con = Server.CreateObject("ADODB.Connection")
	Set rst = Server.CreateObject("ADODB.Recordset")
	con.ConnectionString = "Driver={MySQL Connector/ODBC v5}; Server=web; Port=3306; Option=0; Socket=; Stmt=; Database=test_db; Uid=test; Pwd=;"
	conConexion.Open
	rst.Open "SELECT * FROM test_tbl", con
	rst.Close
	con.Close
	Set rst = Nothing
	Set con = Nothing

VB code:
    Dim con As New ADODB.Connection
    Dim rst As New ADODB.Recordset
    con.ConnectionString = "Driver={MySQL Connector/ODBC v5}; Server=web; Port=3306; Option=0; Socket=; Stmt=; Database=test_db; Uid=test; Pwd=;"
    con.Open
    rst.Open "SELECT * FROM test_tbl", con, adOpenForwardOnly, adLockReadOnly
    rst.Close
    con.Close
    Set rst = Nothing
    Set con = Nothing
[2 Mar 2006 15:31] Daniel Nyström
Has anyone localized the problem yet? I'm also having this issues...
[19 May 2006 13:21] Justin Pretorius
I am using Win2k SP4 and Visual Basic 6 SP 6, and I have also experienced this problem. The error definately occurs after the connection is already established (the connection.open method has already passed without error) and as soon as I try to query the DB with a "SELECT" the whole IDE crashes with the exception error. This only seems to happen with the new ODBC 5 connector, as I reverted back to 3.51 and the problem is gone.
[30 Oct 2006 23:38] Felipe Saldamando
The same problem running the following sample with Win2K VB6SP6 MDAC 2.8SP1 ( Microsoft OLE DB Provider for ODBC Drivers 02.81.1124.0) MySQL ODBC 5.0.5, MySQL 5.0.24a:

   Conexion = "DRIVER={MySQL Connector/ODBC v5 Driver};SERVER=localhost;DATABASE=acuhom;UID=root;PWD=" & Password()
    Set Cnx = New Connection
    With Cnx
        .CursorLocation = adUseClient
        .ConnectionString = Conexion
        .ConnectionTimeout = 0
        .CommandTimeout = 0
        .Open
    End With 'Stop here

Look (break in 'stop here):
Cnx.Errors(0) = 'La operación de múltiples pasos de OLE DB generó errores. Compruebe los valores de estado de OLE DB si es posible. No se realizó ningún trabajo.'
Cnx.Errors(1) = 'El proveedor no admite la propiedad.' (provider does not support the property)

I tryed comparing diferences of Connection properties between 3.51 and 5 ODBC versions and the following Connection properties had diferences:

Accessible Procedures
Catalog Term
Catalog Usage
Data Source Name
DBMS Name
DBMS Version
Driver Name
Driver ODBC Version
Driver Version
Extended Properties
Isolation Levels
Like Escape Clause
Outer Joins
Server Name
Special Characters
SQL Grammar Support
SQL Support
Stored Procedures
Table Term
Transaction DDL
User Name

Most of them are populated after Open connection was sucessfull (in ODBC 3.51), so what property must be modified before opening the connection?
[1 Feb 2007 7:18] Jess Balint
Basic use of ADO is fixed. Please consult forum & mailing list or open new bugs with specific issues.
[30 Jun 2008 12:14] suhail aloor
please tell the connection code of mysql& vb 6.0