Sqlite连接到远程文件使用url c#
本文关键字:url 文件 连接 程文件 Sqlite | 更新日期: 2023-09-27 18:05:34
我一直在尝试让我的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格式"
文件变量由两个值之一填充。
string filelocal = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "''unblocker''sites.db";
或
string remotefile = "http://127.0.0.1/test.db";
给出错误的是远程文件
Connection字符串使用预期在本地文件系统上的db文件作为数据源,看一下这个示例代码。
你可以使用:
Uri uriFormatted = new Uri(file);
uriFormatted.AbsolutePath; // Try to use this value instead to call your function
编辑
SQLite是一个本地独立数据库,用于独立软件
考虑使用SQLitening:
SQLitening是流行的SQLite数据库的客户机/服务器实现。