Hello I'm trying to create a connection string to a AddressBook.mdf file. This file only has 1 table which is "Addresses." This file is located in the root of C:\ Here's what I have:
public Form1()
{
InitializeComponent();
string conn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\AddressBook.mdf";
OleDbConnection myConn = new OleDbConnection();
myConn.ConnectionString = conn;
OleDbDataAdapter daAddress = new OleDbDataAdapter("SELECT * FROM Addresses", myConn);
DataSet dsAddress = new DataSet();
daAddress.Fill(dsAddress, "Addresses");
}
I get an error on daAddress.Fill(dsAddress, "Addresses"); it says "unrecognized database format 'c:\AddressBook.mdf'.
This connection string works on .mdb files, but how do I create a connection string to a .mdf file?
public Form1()
{
InitializeComponent();
string conn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\AddressBook.mdf";
OleDbConnection myConn = new OleDbConnection();
myConn.ConnectionString = conn;
OleDbDataAdapter daAddress = new OleDbDataAdapter("SELECT * FROM Addresses", myConn);
DataSet dsAddress = new DataSet();
daAddress.Fill(dsAddress, "Addresses");
}
I get an error on daAddress.Fill(dsAddress, "Addresses"); it says "unrecognized database format 'c:\AddressBook.mdf'.
This connection string works on .mdb files, but how do I create a connection string to a .mdf file?