Bug #581 Setting ADODB.Connection.DefaultDatabase fails
Submitted: 4 Jun 2003 3:15 Modified: 4 Jun 2003 15:02
Reporter: Harry von Borstel Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51.06 OS:Windows (Windows)
Assigned to: Venu Anuganti CPU Architecture:Any

[4 Jun 2003 3:15] Harry von Borstel
Description:
Using MyODBC with ADO (MSDASQL.1 provider).
Trying to switch to another database (catalog) setting the ADODB.Connection.DefaultDatabase property to the new database's name (e.g. 'dbname').
Sometimes this fails with Err.Number = 0x80004005 and con.Errors(0).Description like "[MySQL][ODBC 3.51 Driver]Unknown database 'dbnameµàxµðxµpyµ'"

How to repeat:
Create some databases on a host.
Connect to one of these DBs using ADO
Switch between the different DBs:

con.DefaultDatabase = "dbname"
con.DefaultDatabase = "test"
con.DefaultDatabase = "test2"

etc...
[4 Jun 2003 14:48] Venu Anuganti
Thank you for your bug report. This issue has been fixed in the latest
development tree for that product. You can find more information about
accessing our development trees at 
    http://www.mysql.com/doc/en/Installing_source_tree.html

Hi !!

Thanks for the nice bug report. This is now fixed in Connector/ODBC 3.52.00 and 3.51.07. The reason for this is driver is not properly null terminating the db string before sending it to the server and thats why you are getting an error while setting it.

The quick work around for this is to send properly null terminated string from ADO.

Thanks,
Venu
[4 Jun 2003 23:46] Harry von Borstel
Hi Venu,

Thanks a lot for this very rapid fixing! I hope that the binaries will be available soon.

<<
The quick work around for this is to send properly null terminated
string from ADO.
>>

I tried this before (con.DefaultDatabase = "dbname" + chr(0)), but it had no effect. It seems that all of the string *excluded* the terminating null has been taken to an internal buffer.

Best regards,

Harry