Windows Server 2008 上的 dBASE ODBC 驱动程序
我有一个 C# winforms 应用程序,可以在我们所有的 XP 机器上正常运行。我们想将其放在新的 Win 2008 64 位服务器上,它会在以下代码中中断:
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(); }
}
我得到的错误是:
ERROR [IM002] [Microsoft][ODBC Driver Manager] 未找到数据源名称且未指定默认驱动程序
如果我查看 64 位 ODBC 数据源管理器,那里没有 dBASE 驱动程序 - 但在 32 位(C:\Windows\SysWOW64\odbcad32.exe)中,它们是 - 我如何让应用程序使用 32 位司机?
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][ODBC 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无法从 64 位应用程序使用 32 位 ODBC 驱动程序。 64 位进程无法调用 32 位 DLL(无论如何都不能直接调用)。 Microsoft 有一篇有关64 位 ODBC 管理员的知识库文章,可能会有所帮助。
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.