How can I connect my Trgovina.mdf with dataGridView?
I follow this tutorial, but it seems that program doesn’t find my database.
Connection string looks like that:
string connString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Klemen\documents\visual studio 2012\Projects\Trgovina\Trgovina\Trgovina.mdf;Integrated Security=True";
Everything else is the same as tutorial example.
Error string is An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'
Full code looks like this.
The tutorial you talk about in your question use an Access Database and thus uses the OleDB engine to reach and work with the database. Instead your connection string use the syntax reserved for SQLServer LocalDB.
You should change your objects to
SqlConnection(instead ofOleDbConnection),SqlCommand(instead ofOleDbCommand) and so on…With these changes you should be able to connect to the automatic instance of SqlServer LocalDB. The rest of the tutorial could work or not, depending on what is present in the MDF file used.