2016-01-12 71 views
1

我開始學習C#和共同的第三部分.NET庫System.Data.Sqlite轉儲數據庫

這裏是我設法到目前爲止寫的,基於在線教程一個非常簡單的代碼;

using System; 
using System.Data.SQLite; 

namespace SQLiteSamples 
{ 
    class Program 
    { 

     static void Main(string[] args) 
     { 
      SQLiteConnection m_dbConnection = new SQLiteConnection("Data Source=dummy.db"); 
      m_dbConnection.Open(); 
      string sql = "select * from my_table"; 
      SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); 
      SQLiteDataReader reader = command.ExecuteReader(); 
      while (reader.Read()) 
       Console.WriteLine(reader["my_col"]); 
      Console.ReadLine(); 
     } 
    } 
} 

我正在尋找一種方法來使用utf8編碼將所有數據庫轉儲到SQL轉儲。這是possbile使用這個庫嗎?

+0

你可以給它是什麼,你想了解更多信息? – LeChosenOne

回答

0

要選擇數據庫中的所有表,請使用SELECT name FROM sqlite_master WHERE type = 'table' 你可以從每個表SELECT * FROM mytable

選擇然後,您可以這樣做DataTable.Load(閱讀器),然後顯示與DataTable的方法,每個表。

編輯:編碼在UTF-8使用字符串

byte[] bytes = Encoding.Default.GetBytes(DataTable's output); 
myString = Encoding.UTF8.GetString(bytes);