2

我一直试图让我的 sqlite 读取远程文件,但只是平淡地告诉我这不支持有解决方法吗?

这是给出错误的函数

    public void Run(string sql,string check,string file)
      {
        SQLiteConnection m_dbConnection;
        string test = "Data Source=" + file + ";Version=3;";
        m_dbConnection = new SQLiteConnection(test);
        m_dbConnection.Open();
        SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
        SQLiteDataReader reader = command.ExecuteReader();
        if (check == "0")
        {
            while (reader.Read())
                comboBox1.Items.Add(reader["name"] + "." + reader["TLD"]);
            comboBox1.SelectedIndex = 0;
        }
        else
        {
           proxy = reader["proxyip"].ToString();
           check = "0";
        }
    }

我得到的错误是“不支持 URI 格式”

文件变量由 2 个值之一填充。

 string filelocal = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\unblocker\\sites.db";

或者

  string remotefile = "http://127.0.0.1/test.db";

给出错误的是远程文件。

4

1 回答 1

0

The Connection string uses as a datasource the db file which is expected on your local file system, take a look at this example code.

You can transorfm this using:

Uri uriFormatted = new Uri(file);
uriFormatted.AbsolutePath; // Try to use this value instead to call your function

EDIT

SQLite is a local standalone database, that is used for standalone software

Consider using SQLitening:

SQLitening is a client/server implementation of the popular SQLite database.

于 2013-03-25T10:38:04.990 回答