1
votes

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?

1
The error-message is self-explanatory. Add a reference to System.Data.Salah Akbari
@S.Akbari I'm using Visual Studio 2017 on Mac os. How can I do that?Rui Pedro ИИ
Try adding a 'using' statement at the top of the code page.wazz
So have a look here maybe stackoverflow.com/a/34674123/2946329Salah Akbari
@wazz no, adding a using directive at the top of the code file does not add a reference. That is not the fix here.Marc Gravell♦

1 Answers

3
votes

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