Hi to every one ..
I have Access database Access 2007 . and i need to connect with ASp.net ..nad i put database in db folder but it gives errors ...
if provide Database1.accdb in connection string (following error)
Unrecognized database format 'C:\Documents and Settings\erum.mirza\My Documents\Visual Studio 2008\Projects\ajax\ajax\db\Database1.accdb'.
if provide Database1. mdb in connection string (following error)
Could not find file 'C:\Documents and Settings\erum.mirza\My Documents\Visual Studio 2008\Projects\ajax\ajax\db\Database1.mdb'.
and here is the piece of code
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string ConnectString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + Server.MapPath("App_Data\\Database1.accdb; Persist Security Info=False;");
OleDbConnection objCon;
OleDbCommand objCmd;
DataSet Ds = new DataSet();
string GetSql = string.Empty;
GetSql = "(SELECT * FROM Table1)";
using (objCon = new OleDbConnection(ConnectString))
{
using (objCmd = new OleDbCommand(GetSql, objCon))
{
OleDbDataAdapter Da = new OleDbDataAdapter(objCmd);
Da.Fill(Ds);
}
}
}
}