0

我目前正在创建与 Web 托管的远程服务器的 ODBC 连接。访问文件位于 ftp 主目录中。

在此代码中运行时,在 m_connection.Open();

        var m_result = new DataTable();

    try
    {
        using (OdbcConnection m_connection = new OdbcConnection(connectionDBString))
        {
            string sql = "SELECT * FROM product";
            m_connection.Open();
            OdbcDataAdapter dataadapter = new OdbcDataAdapter(sql, m_connection);
            dataadapter.Fill(m_result);
            m_connection.Dispose();
            m_connection.Close();
        }
    }
    catch (Exception e)
    {

    }
    return m_result;

以下异常失败

错误 [IM002] [Microsoft][ODBC Driver Manager] 未找到数据源名称且未指定默认驱动程序

无论如何要为 ODBC 连接声明数据源?在cPanel中,我只设置了DSN和Path如下:

DSN : 财富网-网站

路径:e:\virtualhost\domains\wealthhonesthk\home\website.mdb

以下是我的 web.config 的一部分

     <connectionStrings>
    <add 
      name="ODBCDataConnectionString" 
      connectionString="DSN=wealthhonesthk-website;Driver={Microsoft Access Driver (*.mdb)};FILEDSN=ftp:/210.245.166.72/home/website.mdb;Dbq=ftp:/210.245.166.72/home/website.mdb;Uid=;Pwd=; curly=false;"
      providerName="System.Data.Odbc"
    />
  </connectionStrings>
4

3 回答 3

1

You tend to use a DSN when you don't define a connection string in a config file (like in old VB6 days). Since you're using a config file, you really don't need a DSN. Why not use a connection string like:

Driver={Microsoft Access Driver (*.mdb)};Dbq=ftp://210.245.166.72/home/website.mdb;Uid=Admin;Pwd=;?

Also, having your MDB file mapped to a FTP location may be a problem; why not map a network drive to that location? This way, your connection string might look like:

Driver={Microsoft Access Driver (*.mdb)};Dbq=X:\myNetworkLocation\website.mdb;Uid=Admin;Pwd=;

Lastly, why are you defining a FILEDSN and a Dbq parameter for your connection string?

In short, I'd recommend getting rid of the DSN part of your connection string and use a non-ftp location for your MDB file.

于 2013-04-01T11:52:38.933 回答
0

以下是您需要的有关连接字符串的所有信息:

http://www.connectionstrings.com/access

http://www.connectionstrings.com/access-2007

于 2013-03-30T13:35:44.443 回答
0

看看以下

http://www.connectionstrings.com/

应该能帮到你。

As you are trying to connect to Oracle Database, you might need to have Oracle Client installed.

于 2013-03-30T15:07:31.037 回答