2013-01-08 41 views
0

我想學習如何使用SQLite與C#(單/ MonoDevelop的)。 我已經包括在我的解決方案SQLite的參考,我試圖編譯這個簡單的代碼:單MonoDevelop的和SQLite

using System; 
using System.Data; 
using System.Data.SQLite; 

namespace SqliteTest 
{ 


class SqliteTest 
{ 
    static void dbstuff() 
    { 
     //Creating DB 
     SQLiteConnection.CreateFile("MyDatabase.sqlite"); 
     //Creating a Connection 
     SQLiteConnection m_dbConnection; 
     m_dbConnection = new SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;"); 
     //Conntecting 
     m_dbConnection.Open(); 
     //Run some sql commands 
     string sql = "CREATE TABLE highscores (name VARCHAR(20), score INT)"; 
     SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); 
     command.ExecuteNonQuery(); //This command just indicae the number of rows that have been modified 

    } 

    static void Main() 
    { 
     dbstuff(); 
    } 
} 
} 

但我得到這個錯誤:

The type 'System.Data.Common.DbConnection' is defined in an assembly that is not referenced 

我怎樣才能解決這個問題?

我與C#是一個新手,我希望有人能指點正確的方向。

回答

0

在文件前面加

using System.Data.Common; 

+0

我已經試過,但沒有運氣。它說Syste.Data中不存在「Common」數據 –

+0

項目中是否存在對SQLite的引用? –

+0

是,System.Data.SQLite.dll和SQLite.Designer.dll –