数据源名称未找到和指定默认驱动程序 [英] Data source name not found and no default driver specified

查看:457
本文介绍了数据源名称未找到和指定默认驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在问口WinForms应用程序,它使用了MVP模式切换到网页。该应用程序,除其他事项外,上传一个CSV文件,数据表,然后做一些工作。

I have been asked to port a WinForms app that uses the MVP pattern over to a webpage. The app, amongst other things, uploads a CSV file to a DataTable and then does some work.

CSV文件上传到服务器确定,然后阅读下面的code

The CSV file is uploaded to the server OK and then read with the following code

string connectionString = @"Driver={Microsoft Text Driver (*.txt; *.csv)};Extensions=asc,csv,tab,txt;Persist Security Info=False;Dbq=C:\Temp\";

//check that file exists and in correct format
if (File.Exists(this.WorkingFileName))
{                    
    using (OdbcConnection connection = new OdbcConnection(connectionString))
    {
        // Determine number of rows
        string selectCount = "select count(*) from [MyFile.csv]");

        using (OdbcCommand command = new OdbcCommand(selectCount, connection))
        {
            connection.Open();
        }
    }
}

在这一点上,我得到了错误:

at this point I get the error:

ERROR [IM002] [微软] [ODBC驱动程序   管理器]数据源名称未找到   并且没有指定默认驱动程序

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

现在的code正常工作在的WinForms,但无法在网络上。有什么我需要在IIS中改变,我的配置文件或其他东西来得到这个code的工作?或者是有什么更根本的,我需要做什么?

Now the code works fine in WinForms but fails on the web. Is there something I need to change in IIS, my config file or something else to get this code to work? Or is there something more fundamental I need to do?

更新

行,所以我哪些工作是我的两个code版本之间的不同:在的WinForms版本,只要我改成了64位它扔了同样的错误运行为32位。看到: <一href="http://stackoverflow.com/questions/3454701/32-bit-text-drivers-microsoft-access-microsoft-excel-and-text-files-from-a-6">32-bit从64位应用程序的文本驱动程序(Microsoft Access中,Microsoft Excel和文本文件),在Windows 7

OK so I worked out what was different between my two code versions: The WinForms version was running as 32-bit, as soon as I changed it to 64-bit it threw the same error. See: 32-bit Text drivers (Microsoft Access , Microsoft Excel and Text files ) from a 64 bit application on windows 7

要解决的事情,我从<一个安装在访问的64位驱动程序href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=13255">http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=13255但我仍然得到同样的错误。

To fix things I installed the Access 64-bit drivers from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=13255 but I still get the same error.

如果我检查我的ODBC数据源管理器,我可以看到的Microsoft Access文本驱动程序(*。txt文件,*。CSV)| 14.00.47600.1000 |微软公司| ACEODBC.dll

If I check my ODBC Data Source Administrator I can see "Microsoft Access Text Driver (*.txt, *.csv) | 14.00.47600.1000 | Microsoft Corporation | ACEODBC.dll

因此​​,它看起来像他们装好了,那么,为什么它仍然会失败?

So it looks like they're installed OK, so why would it still be failing?

推荐答案

OK,我发现这个问题。只是为了总结所有的部分我的解决方案。

OK, I found the problem. Just to summarise all the parts to my solution.

  1. 卸载所有32位Office应用程序(用于步骤2)
  2. 安装访问的64位驱动程序
  3. 重新安装所有32位Office应用程序
  4. 更​​改连接字符串 两个地方可以看出<一href="https://$c$c.google.com/p/fdotoolbox/source/browse/trunk/FdoToolbox.Ex$p$pss/Controls/Odbc/OdbcText.cs?spec=svn1085&r=1085"相对=nofollow>这里:

  1. Uninstall any 32-bit Office apps (required for step 2)
  2. Install the Access 64-bit drivers
  3. Re-install any 32-bit Office apps
  4. Change the connection string in TWO places as can be seen here to:

@驱动程序= {Microsoft Access中的文本驱动程序(*。txt文件,*。CSV)};扩展=递增,CSV,制表符,TXT;坚持安全信息= FALSE; DBQ = C:\ TEMP \

@"Driver={Microsoft Access Text Driver (*.txt, *.csv)};Extensions=asc,csv,tab,txt;Persist Security Info=False;Dbq=C:\Temp\"

需要注意的是:

  1. 的驱动程序名称已更改为 微软的访问文字驱动程序
  2. 的分隔符的文件扩展名 已经从一个分号 到逗号
  1. The driver name has been changed to Microsoft Access Text Driver
  2. The delimiter for the file extensions has been changed from a semi-colon to a comma.

我没有发现它给我带来了很多痛苦的逗号变化: - (

I didn't spot the comma change which caused me a lot of pain :-(

这篇关于数据源名称未找到和指定默认驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆