0

I am trying to connect to an Access DB using odbcConnection through ConnectionString in Properties menu in VS C# 2010 Express version. I get an error that tells me this option isn't enable in Express edition and I am forced to use other versions or code.

How I can use code for do this connection?

Loofer
  • 6,841
  • 9
  • 61
  • 102
user3346389
  • 17
  • 1
  • 6

1 Answers1

5
using System.Data.Odbc;

using(OdbcConnection myConnection = new OdbcConnection())
{
    var myConnectionString = @"Driver={Microsoft Access Driver (*.mdb)};" + 
        "Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=;";
    myConnection.ConnectionString = myConnectionString;
    myConnection.Open();

    //execute queries, etc
}

See ConnectionStrings

Reproduced from here.

Community
  • 1
  • 1
Shakti Prakash Singh
  • 2,414
  • 5
  • 35
  • 59