Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can any on help with me the connection string for connecting the Database in ms access 2007 .
iam using windows 2007, 64 bit os..
Posted
Comments
Prerak Patel 6-Jun-11 5:56am    
Try Microsoft.ACE.OLEDB.12.0
Ragi Gopi 6-Jun-11 6:02am    
@Prerak Patel
then i git this error
"The 'Microsoft.ACE.OLEDB.12.0' provider is not registered ";;;;

you can use this to get your job done:

MSIL
OleDbConnection cnn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=c:\database.accdb;Jet OLEDB:Database Password=password;");
 
Share this answer
 
Comments
Ragi Gopi 6-Jun-11 6:11am    
@Uday P.Singh

then i got this error
"The 'Microsoft.ACE.OLEDB.12.0' provider is not registered "
Uday P.Singh 6-Jun-11 6:27am    
Switched the target CPU in Advanced Compile Options to x86 bit application.
 
Share this answer
 
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\BackupFile\ClearTolerance1.mdb;Persist Security Info=False
 
Share this answer
 
Comments
Ragi Gopi 6-Jun-11 5:48am    
@sindhu
this not working
Use this:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\BackupFile\ClearTolerance1.mdb;Persist Security Info=False
 
Share this answer
 
Comments
Ragi Gopi 6-Jun-11 5:50am    
@Ramalinga Koushik
this wil not work
because Microsoft.Jet.OLEDB.4.0 is not seen in Windows7 , 64 bit OS.
Member 13366535 18-Aug-17 7:29am    
I am getting error as The Microsoft.ACE.OLEDB.12.0 provider is not registered on the local machine

My code is
public string Upload(HttpPostedFileBase uploadFile)
{
StringBuilder strValidations = new StringBuilder(string.Empty);
try
{
if (uploadFile.ContentLength > 0)
{
string filePath = System.IO.Path.Combine(HttpContext.Server.MapPath("../Uploads"),
System.IO.Path.GetFileName(uploadFile.FileName));
uploadFile.SaveAs(filePath);
DataSet ds = new DataSet();

//A 32-bit provider which enables the use of

//string ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties=Excel 12.0;";
//string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 12.0;";
string ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source = " + filePath + ";Persist Security Info = False";

using (OleDbConnection conn = new System.Data.OleDb.OleDbConnection(ConnectionString))
{
conn.Open();
using (DataTable dtExcelSchema = conn.GetSchema("Tables"))
{
string sheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
string query = "SELECT * FROM [" + sheetName + "]";
OleDbDataAdapter adapter = new OleDbDataAdapter(query, conn);
//DataSet ds = new DataSet();
adapter.Fill(ds, "Items");
if (ds.Tables.Count > 0)
{
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
//Now we can insert this data to database...
}
}
}
}
}
}
}
catch{ }
return "";
}
}
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900