2013-03-25 21 views
1

我一直試圖讓我的SQLite讀取遠程文件,但只是flatout告訴我這不支持有沒有解決這個?Sqlite連接到遠程文件使用URL C#

這裏是給出了錯誤

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

的一個,使該誤差爲遠程文件。

+0

你會得到什麼錯誤?確切的錯誤。 – CloudyMarble 2013-03-25 10:19:35

+0

參數文件的確切值是多少? – CloudyMarble 2013-03-25 10:34:23

回答

0

連接字符串將數據源用作本地文件系統上預期的數據庫文件,請查看此example code

可以使用transorfm這樣的:

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

編輯

SQLite是一個本地獨立的數據庫,也就是用於獨立的軟件

考慮使用SQLitening

SQLitening是流行的SQLite數據庫的客戶端/服務器實現酶。

+0

以及我可以得到它在本地文件上工作,但只要我開始使用IP或URL來訪問它不再工作的文件。我在這裏使用127.0.0.1的原因是因爲我正在運行一個小型服務器來測試它。 – Harry 2013-03-25 10:46:49

+0

SQLite是一個嵌入式數據庫,它不打算用作客戶端服務器。你爲什麼不使用SQLitening? – CloudyMarble 2013-03-25 10:53:07

+0

說實話我從來沒有聽說過XD。 – Harry 2013-03-25 10:57:21