3

I created a Windows forms project in C# with Visual Studio 2012 that connects to a MS Access database. When I finished it, I went into project properties and changed the .NET Framework from 4.5 to 4.

When I changed the .NET Framework, the database connection is lost. I even changed it back to .NET Framework 4.5 and test connection says is OK but I can't connect to the database.

My connection string is:

string constring = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\libereas\Documents\Visual Studio 2012\Projects\kataxorisiOplon\kataxorisiOplon\bin\Debug\resources\data.mdb";

Why is this happening?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • So, the test query you've written works okay? What error(s) are you getting in your subsequent queries? – Nathan Champion Nov 24 '18 at 09:42
  • there are no error when i run it from visual studio. The dataGridView that loads the db is empty. Even if i try catch the con.Open() it does't find errors. But when i run the code from debug folder says "The Microsofr.jet.OLEDB.4.0 provider is not registered on the local machine – stratos lumpereas Nov 24 '18 at 10:04
  • You sure it's no a version (32/64bit) issue? It's known to cause compilation issues. https://stackoverflow.com/questions/1991643/microsoft-jet-oledb-4-0-provider-is-not-registered-on-the-local-machine – Nathan Champion Nov 24 '18 at 10:06
  • 32/64 on what? On 'buld' -> platform target though is says 'any pc'. I have changed many projects that way from 4.5 .net framework to 4.0 but none of them used database connection. – stratos lumpereas Nov 24 '18 at 10:13
  • Yes, change it to 32 bit (probably) as the necessary references will change based on OS architecture. – Nathan Champion Nov 24 '18 at 10:37
  • Can't believe i lost 2 days for that. That was it. But if i buid it can i run it on a win 64 pc? – stratos lumpereas Nov 24 '18 at 11:00
  • Yes, it will run okay on 64bit machines. However, if memory is an issue you could run into problems. – Nathan Champion Nov 24 '18 at 11:01
  • I run into them with SQL Server Management from Microsoft because it's strictly 32bit as well. – Nathan Champion Nov 24 '18 at 11:01
  • ok thanx can you write that as an answer? – stratos lumpereas Nov 24 '18 at 11:02

1 Answers1

1

You sure it's not a version (32/64bit) issue? It's known to cause compilation issues. http://stackoverflow.com/questions/1991643/

Nathan Champion
  • 1,291
  • 1
  • 14
  • 23