Mono Monodevelop和SQLite

时间:2013-01-08 14:32:13

标签: c# windows sqlite mono monodevelop

我正在尝试学习如何将SQLite与c#(mono / 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#的新手,我希望有人能指出我正确的方向。

1 个答案:

答案 0 :(得分:0)

添加

using System.Data.Common;

在文件前面。