1

I'm developing an application ASP.NET Core 2.2 on .NET Framework 4.7.2 that needs access to SQL Server, MySQL, Sap Hana, and DB2 thru ODBC. I have installed the ODBC Driver on Windows, the user fill a form with credentials and send the form to validate the access

The app builds a connection string and opens a connection to validate the access. The problem is that only work with SQL Server when I try with MySQL, Oracle or other I got the error Message "[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".

The code I use to validate the connections string is in a separate .NET Framework Library and when I use it in a console app it works and when consuming it in ASP.NET CoreProject don't

using (OdbcConnection connection = new OdbcConnection("Driver={MySQL ODBC 5.1 Driver};server=localhost;Port=3306;Database=sakila;Uid=user;pwd=Password;Option=3;"))
{
  try
  {
     connection.Open();
  }
  catch (Exception e)
{
   // return error message
}
}

I expect it works in ASP.NET Core

  • Have you tried the way to install `32-bit` MySQL ODBC 5.1 Driver like the [link](https://stackoverflow.com/questions/8240050/connecting-to-mysql-causes-error-data-source-name-not-found-and-no-default-driv) has suggested? Also refer to [here](https://stackoverflow.com/questions/17115632/microsoftodbc-driver-manager-data-source-name-not-found-and-no-default-drive) – Ryan Mar 25 '19 at 03:15
  • [Visual Studio is 32-bit in some places, and 64-bit in others](http://wikis.openlinksw.com/UdaWikiWeb/MsSqlOn64bitWin). This issue should be resolved if you (1) install both 32-bit and 64-bit flavors of each ODBC Driver; (2) install both 32-bit and 64-bit ADO.NET Providers for ODBC; and (3) use only System DSNs, named and configured identically in [32-bit and 64-bit Administrators](http://wikis.openlinksw.com/UdaWikiWeb/Win32vs64OdbcAdmin). – TallTed Mar 25 '19 at 14:19
  • 2
    @XingZou I have 32-bit Odbc Driver but my Applications was configuring to run 64. I changed the release configuration to x86 and now works. – Benjamín Camacho Castro Mar 26 '19 at 15:37

0 Answers0