dBASE ODBC drivers on Windows Server 2008
I have an C# winforms app that works fine on all our XP machines. We want to put it on a new Win 2008 64 bit server and it breaks on the following code:
using (OdbcConnection oConn = new OdbcConnection())
{
oConn.ConnectionString = @"Driver={Microsoft dBase Driver (*.dbf)};SourceType=DBF;SourceDB=" + filePath + ";Exclusive=No; Collate=Machine;NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO;";
oConn.Open();
OdbcCommand oCmd = oConn.CreateCommand();
oCmd.CommandText = "SELECT DISTINCT Mid(POSTCODE,1,Len(POSTCODE)-2) AS sector FROM " + shortfilename + ".dbf;";
OdbcDataReader dr = oCmd.ExecuteReader();
try
{
while (dr.Read())
{
lstSectors.Items.Add(dr.GetString(0));
}
}
catch
{
string err = "Error!";
}
finally { dr.Close(); }
}
The error I get is:
ERROR [IM002] [Microsoft][ODB开发者_C百科C Driver Manager] Data source name not found and no default driver specified
If I look at the 64 bit ODBC Data Source Admin, there are no dBASE drivers there - but in the 32 bit (C:\Windows\SysWOW64\odbcad32.exe), they are - how do I get the application to use the 32 bit drivers?
It is not possible to use a 32-bit ODBC driver from a 64-bit application. 64-bit processes cannot call into 32-bit DLLs (not directly anyway). Microsoft has a KB article about the 64-bit ODBC administrator that might help.
精彩评论