The bottom line is the first time I work with C # and the Microsoft Access database file. There are no errors, but causes class exceptions. Please review the code, it is not great. And poke where wrong.

class DB { static string connectionString = "provider=Microsoft.Jet.OLEDB.4.0;" + "datasource=Kursach.mdb"; static OleDbConnection myOleDbConnection = new OleDbConnection(connectionString); static OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand(); static OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader(); public string sql_query(string query, string row) { myOleDbCommand.CommandText = query; myOleDbConnection.Open(); myOleDbDataReader.Read(); return myOleDbDataReader[""] + row; } } 

alt text

  • Understood, really the problem was in the connection .. Thank you who responded. - smail2133

1 answer 1

Take a look here . There may be an error in the connection string. For example not datasource and Data Source