Sqlite使用url C#连接到远程文件

时间:2013-03-25 10:16:15

标签: c# sqlite

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

这是给出错误的函数

    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";

提供错误的是远程文件。

1 个答案:

答案 0 :(得分:0)

Connection字符串使用本地文件系统上预期的db文件作为数据源,请查看此example code

您可以使用以下方式进行转换:

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

修改

SQLite是一个本地独立数据库,用于独立软件

考虑使用SQLitening

SQLitening是流行的SQLite数据库的客户端/服务器实现。