Bug #25316 Simple VB/ADO Query Fails with "No database selected"
Submitted: 28 Dec 2006 16:43 Modified: 10 Jul 2007 5:46
Reporter: Jess Balint Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.00.10 OS:Windows (windows)
Assigned to: Jess Balint CPU Architecture:Any
Tags: ODBC5-RC

[28 Dec 2006 16:43] Jess Balint
Description:
Trying to issue a simple query from VB/ADO fails with:

[MySQL][MyODBC 5.00.11][MySQL] 1046 No database selected

How to repeat:
Use this VB code (add Microsoft ActiveX Data Objects reference to project):

        Dim constring As String
        constring = "DRIVER={MySQL Connector/ODBC v5};server=localhost;uid=myodbctest;pwd=myodbctest;database=test;Option=3"

        Dim Con As ADODB.Connection
        Con = New ADODB.Connection
        Con.ConnectionString = conString
        Con.Open()

        Con.Execute("select * from xdata")
[12 Jan 2007 13:00] Renato Gontijo
I had the same problem on MySQL 5.0.27 with MyODBC 3.51.12 on Windows XP. I'm using VB6 and ADO 2.8.

After connect to database with ADO is necessary to send command:
Con.Execute("USE MyDATABASE;")

With other versions of database like 5.0.22 this problem doesn't happen. 
I guess that some modification on connection routine made this error. I'm having problems to print reports with Crystal Reports XI with version 5.0.27.
[13 Jan 2007 4:30] Laurensius Hermawi
This error appeared again when I want to add or update data with this command

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM tablename WHERE fieldname= 'XXX' ", Con, adOpenForwardOnly, adLockOptimistic

rs!fieldname1="DDD"

rs.update
----------
[24 Jan 2007 23:22] Jess Balint
Problem with DSN-less connect string parsing. Fix committed in rev777.
[18 Jul 2007 4:26] kudo edokawa
mangwantong/ra
I made authen to msql database by use ODBC 5 but i can not authen
.because error  Fails with "No database selected".
what can i do??????