Search code examples
c#databasesqlitedatabase-connection

Error CS0012: The type 'DbConnection' is defined in an assembly that is not referenced


I got this error

Error CS0012: The type 'DbConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. (CS0012)

I'm trying to do this:

private void SetConnection()
{
   sql_con = new SQLiteConnection("DataSource=kyriosDB.db;Version=3;New=False;Compress=True;");
}


public void ExecuteQuery(string txtQuery)
{
    SetConnection();
    sql_con.Open();
    sql_cmd = sql_con.CreateCommand();
    sql_cmd.CommandText = txtQuery;
    sql_cmd.ExecuteNonQuery();
    sql_con.Close();
} 

Someone can help me?


Solution

  • I solved it by going to Project - Add references then I manually add System.Data on Mac... I don't know about VS windows but hopefully it's the same