Link to home
Start Free TrialLog in
Avatar of shacho
shacho

asked on

Access Asking for Connection Parameters with Passthrough Query

I have created a link to a MySQL table in an Access DB.
I can run regular queries on the link with no problem.
If I try to run a passthrough query on it, however, Access asks me to select the data source (even though the connection parameters are stored in the link).
I'm not sure why and I don't think this is expected behavior for Access.
Can someone help me troubleshoot?

Mike

User generated image
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Your query needs a connection string. How should it otherwise know where to pass your query?

The property ODBCconnection has to hold a string starting with ODBC; as here:

ODBC;Driver=YourMySqlDriver;DATABASE=YourDatabase;SERVER=HostnameOrIpAddress;User=Username;
You can open one of your linked tables in design view and study the properties. You can probably copy and paste the full connection string from this to your query.

/gustav
Avatar of shacho
shacho

ASKER

Yes - it can be done this way.  But if I do it that way, then it is not referencing the linked table.  I could delete the link and the passthrough would still work.  In fact, this is what I'm doing now.  I expected that Access would use the linked table to make the connection, but I guess Access doesn't look at the query contents at all if it's a passthrough.  If so, then the behavior is expected.
Pass-through queries are just that, they pass the query (or any valid SQL) from Access directly to you MySQL database, where the SQL is processed.  This requires the connection string because, as Gustav indicated, the query does not know anything about the tables involved.  I generally get the connection string by typing the following in the immediate window:

?Currentdb.Tabledefs("SomeLinkedTableName").Connect

I then paste this into the connection string in the Pass-Through query.  Don't forget to set the queries ReturnsRecords to the the appropriate value (Yes or No).
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shacho

ASKER

Makes sense.  Thanks Gustav!

Mike
Avatar of shacho

ASKER

Dale - sorry - I didn't see your post until now.  If you request a point reallocation, I'll do so.
you're good.  Gustav answered the question, I just piled on with a bit of additional info.
Avatar of shacho

ASKER

OK!  Thanks again.