-1

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

4

1 回答 1

0

添加

using System.Data.Common;

在文件前面。

于 2013-01-08T14:36:47.573 回答