简体   繁体   中英

MySQL ODBC connections (again)

I know this question has been asked many times but my variation is slightly different and I'm pulling my hair out after spending several hours trying to get one line of code to work. I have a MySQL database and am trying to connect using ODBC. I'm on Windows 10 version 1909.

Line 13: OpenString ="DRIVER={MySQL ODBC 8.0 ANSI Driver};SERVER=localhost;DATABASE=collections;UID=edited_out;PWD=edited_out;"
Line 14: Conn = Server.Createobject("ADODB.Connection")
Line 15: Conn.open = OpenString

The code quoted works fine on my main PC with Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0 and DRIVER={MySQL ODBC 5.3 ANSI Driver}. On the test PC with an almost identical configuration, the exact same code with the exception of the driver name fails. (Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0 and DRIVER={MySQL ODBC 8.0 ANSI Driver} or, for that matter, DRIVER={MySQL ODBC 8.0 Unicode Driver} - both installed.) Please see the attached image for evidence. I get the well-known and depressing "Data source name not found and no default driver specified". Code snippet and drivers

I realise that this error is almost always due to getting the driver name wrong. However, I've checked and rechecked my syntax and the driver installation. I know there's nothing obviously wrong with my ODBC installation since I installed LibreOffice purely for testing and was able to connect to the same database via ODBC within seconds on the same PC using the same driver shown here. Is there something different or particularly troublesome about the ODBC version 8.0 drivers? Do I need to try to downgrade this one to 5.3?

Thanks for any help.

FIX: Disable 32 bit applications for your site if working with 64 bit!

(Answering my own question in the hope that it helps somebody.) I figured it out. The connection string was a red herring. Further detective work led me to a post that advised checking application pools in IIS. The advice was to enable 32 bit applications under Advanced Settings for your site if you have any 32 bit applications, which is fairly obvious.

However, my application is 64 bit and I noticed that this option was DISABLED on my working PC. Disabling it on the other PC restored the connection: evidently Windows was defaulting to a nonexistent 32 bit driver and showing an ambiguous error message when this failed. Software writers seem to dig a lot of these holes for users to fall into...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM