views:

41

answers:

2

I have created a linked table to a MySQL table in MS Access 2003. I used the the mysql-connector-odbc-5.1.6-win32 driver I found on the MySQL site. When I view the table I can only see 70 characters in a VARCHAR(255) field. Has anybody had any luck using MySQL from MS Access?

A: 

Just a guess, i'm not sure if 70 was an exact number, but:

255/4 = 63.75 (so 63) So that means a 255 byte limit would allow only 63 4-byte characters.

I am not sure if somewhere on the MySQL<->Access it is making the encoding weird.

If your table is using a bigger string encoding, maybe that is limiting the number of characters?

I could also be totally wrong.

webdestroya
A: 

It's been a while since I've worked with MySQL tables from within MS Access, but from what I remember, I don't think Access directly uses MySQL's field definitions when linking tables. I can't remember if this was for tables or pass-through queries, but I remember that sometimes it seemed that Access based it's field definitions on the data contained in the first few rows it downloaded.

There may be an optional parameter that you can specify in the connection string to help with setting up correct field definitions. Check out www.connectionstrings.com or MySQL's website for more information.

I actually got away from linking MySQL tables in Access because the performance of queries that joined two tables together was so horrible. I did, however, use pass-through queries quite frequently with a great deal of success. When using pass-through queries, the work of the query is done by the MySQL engine and not the access JET engine, which usually results in much better performance because only the end data is coming down to the client. However, you lose the WYSIWYG benefit of query editing in Access when you use pass-through queries.

One complex solution I would use involved using a pass-through query to automatically create a table that I could periodically manually update. I would have to manually tweak the table definition during set up (since the query didn't pull down field definitions), but once I tweaked the table, I could programmatically update the table with MySQL data. I used this technique when I had to do a lot of complicated things in Access and was pulling down tons of data.

Ben McCormack
Jet will make good decision and send most data requests to the server if the ODBC driver provides it with sufficient metadata. I'd blame the ODBC driver for problems like this, as Access with SQL Server over ODBC is very efficient, hardly ever pulling all the data for queries that can be processed on the server.
David-W-Fenton
Thank Ben.I think I will try pass-thru queries. Do I have to install the ODBC driver on all client machines? Can I do this without having to create a DSN for each machine?
Paul
I was able to make the linked tables DSN-less by running the code found here: http://www.accessmvp.com/djsteele/DSNLessLinks.htmlStill have not figured out the problem with the truncated field
Paul
@PNG Whenever I worked with the ODBC driver, I had to install it on every machine, which was a pain. I always programmatically set up my connections in code, but I still had to install the driver manually.
Ben McCormack
@David You make a good point. I never had much luck with MySQL linked tables. I wonder, though, even with SQL Server over ODBC, how much complexity can the JET engine handle. If you start using nested queries or queries calling other queries, is the JET engine smart enough not to pull down the entire table to process it? I think that's always where I ran into trouble, but I can't specifically remember.
Ben McCormack
It entirely depends on the particular queries and the schema of the database you're running against. Jet is smart enough with nested saved access QueryDefs to hand them off to the server for individual processing, in my experience. My philosophy is try it the Access way. If it's slow, look at the SQL trace and see what's slowing things down and alter your Access SQL accordingly. If necessary, move part of it server-side, either with views on the server or using passthroughs, and in some cases stored procedures. BTW, do current versions of MySQL have any trace functionality?
David-W-Fenton
@David I'm not really sure. We were only using MySQL as a reporting server, so I never got very close to the configuration of the server.
Ben McCormack