1
votes

The below code reads dbf files on local machine correctly, but when deployed to Windows server 2012r2, it throws exception:

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

try
{
    OdbcConnection obdcconn = new OdbcConnection();
    //obdcconn.ConnectionString = "Driver={Microsoft dBase Driver (*.dbf)};SourceType=DBF;SourceDB=" + strTempDirectory + "\\;Exclusive=No; NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO;";
    obdcconn.ConnectionString = "Driver={Microsoft dBase Driver (*.dbf)};SourceType=DBF;SourceDB=" + strTempDirectory + "\\";
    obdcconn.Open();
    System.Data.Odbc.OdbcCommand oCmd = obdcconn.CreateCommand();
    oCmd.CommandText = "SELECT * FROM " + Path.Combine(strTempDirectory, tempFileName); // Specify full path including dbf filename with extension

    AVSNAssignmentDetails = new DataTable();
    AVSNAssignmentDetails.Load(oCmd.ExecuteReader());
    obdcconn.Close();
    ErrorLogger.LogActivity(string.Format("\t - Dbf data retrived successfully for file {0} of ClaimNumber: {1}", fileInfo.Name, _strClaimNumber), _strActivityLogFileName);
}
catch (Exception ex)
{

}

I found that no odbc driver was installed on the server, so I installed ODBC Driver 13 for SQL Server but still getting the same error.

1

1 Answers

1
votes

When enabled application pool to 32 Bit application it works as per post found here: https://www.codeproject.com/Tips/305249/ERROR-IM-Microsoft-ODBC-Driver-Manager-Data-sou