Bug #3391 cannot insert data into a microsoft word document using odbc consistently
Submitted: 5 Apr 2004 3:29 Modified: 25 Jun 2004 18:48
Reporter: Will Sandenbergh Email Updates:
Status: Can't repeat Impact on me:
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51.06 OS:Microsoft Windows (WinXP)
Assigned to: Peter Harvey CPU Architecture:Any

[5 Apr 2004 3:29] Will Sandenbergh

When trying to connect to a MYSQL server using odbc and microsoft word
in order to insert data into a word document, the tables on the database or even
the databases on the server are not always available.
Looking at the dumps, both the SQL.LOG and myodbc.log  it appears the name of the 
database is being corrupted.

How to repeat:

Open microsoft word and start a new document.
Choose 'insert database' from the database toolbar.
From the database dialog choose the 'data source -> get data' button.

In the select data source dialog click 'New source' button.
In the data connection wizard select 'ODBC DSN' from the available options, then click 'next' button.

In the 'connect to ODBC data source' window select an ODBC data source
that has been defined for connecting to the MySQL server and click 'next'.

Now the wizard should show 'Select Database and table'. Sometimes
it shows a message 'unable to obtain a list of tables from the data source.' but
trying again works.

There should be a combo box with a list of available databases and when you select a database you should see the list box populate itself with a list of tables for the database you selected.

This does not always work. Sometimes you will see the list of tables for a selected database, sometimes not.
If you try selecting the databases one by one to see what tables are available sometimes they disappear the second time you select them them.

Suggested fix:

Check the function that is returning a list of database names is terminating the
strings properly. 
When I was  tracing through the source code, the function 'mysql_select_db'
would contain the name of the database in the 'char *db' function paramater
but also garbage characters i.e. the name was not terminated properly. 
I experimented by forcing the string to contain the right database name and then it works OK.
[13 Apr 2004 18:35] MySQL Verification Team
Verified with Word 2003.
[14 Apr 2004 8:07] MySQL Verification Team
I continued to test this issue and found that the problem was
how the data source file was build by the Word wizard. Now
I can insert data consistently. Please verify if your file
has similar lines like the below:

<odc:Connection odc:Type="ODBC">
   <odc:ConnectionString>DSN=myodbc3-test;DESC=MySQL ODBC 3.51 TEST DSN;DATABASE=test;SERVER=localhost;UID=root;PASSWORD=;PORT=3306;OPTION=524295;STMT=;</odc:ConnectionString>
   <odc:CommandText>SELECT * FROM `test`.`wordtest`</odc:CommandText>
[26 Apr 2004 5:07] Will Sandenbergh
Yes, my .odc files contain these lines.
By editing and altering the files I can get word to insert data.
This still does not explain the corruption I saw inside the odbc driver.

[25 Jun 2004 18:48] MySQL Verification Team
I was able to insert data like explained before.
[19 May 2005 20:56] Rudok Simintiv
I can repeat this issue as Will explains it when attempting to create a .odc file using a ODBC:MySQL connection. However with mine, it ALWAYS gives me the "Unable" message and then when I press next it will fill the list box with available databases, but doesn't give any listing of tables. What's going on with this??
[13 Aug 2009 3:46] uzumaki naruto
I have build a database in a MySQL. then i build a interface in the microsoft word.. how i want to connect a database with my ms word using VBA....
[13 Aug 2009 3:56] uzumaki naruto
actualy the database i was doing in MYsql 5.1