locked
Ms Access and Asp.net RRS feed

  • Question

  • User81789783 posted

    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'.

     

     

     

     

     

    Friday, March 22, 2013 1:44 AM

Answers

  • User81789783 posted

    I installed database engine (Compatible one)with same office version and its working fine and shine ...... (cheers :)

     

     

    Thanks

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 22, 2013 7:54 AM

All replies

  • User-1315512054 posted

    Hello,

    What is your database name?

    Regards

    Friday, March 22, 2013 1:52 AM
  • User81789783 posted

    Database1.accdb or may be ms access call it  Database1.mdb

    Friday, March 22, 2013 1:54 AM
  • User-1716253493 posted

    try place Database1. mdb in app_data folder

    Friday, March 22, 2013 2:52 AM
  • User81789783 posted

    the error is

    Unrecognized database format 'C:\Documents and Settings\erum.mirza\My Documents\Visual Studio 2008\Projects\ajax\ajax\App_Data\Database1.accdb'.

     

    and the piece of code is

        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);
                        }
                    }
    
    
    
                }
            }

    though  i have moved database to folder mentioned by U i.e App_data


     

    Friday, March 22, 2013 3:06 AM
  • User-1716253493 posted

    string ConnectString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + Server.MapPath("~/App_Data/Database1.accdb") + "; Persist Security Info=False;");

    Friday, March 22, 2013 4:14 AM
  • User81789783 posted

    thanks for your reply

     

    i have changed connection string as follows but get an error

    Unrecognized database format 'C:\Documents and Settings\erum.mirza\My Documents\Visual Studio 2008\Projects\ajax\ajax\App_Data\Database1.accdb'.

    let me share line too

    string ConnectString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + Server.MapPath("~/App_Data/Database1.accdb") + "; Persist Security Info=False;" ;

     

    Friday, March 22, 2013 4:19 AM
  • User-1716253493 posted

    use access 2003 file

    If you want use access 2010 use “Microsoft.ACE.OLEDB.12.0” intead Microsoft.Jet.OLEDB.4.0

    Download here

    http://www.microsoft.com/en-us/download/details.aspx?id=13255

    Friday, March 22, 2013 4:30 AM
  • User81789783 posted

    you mean there is no connectivity  for 2007 in any way :(

    Friday, March 22, 2013 4:35 AM
  • User-1716253493 posted

    use Microsoft.ACE.OLEDB.12.0, see my above post

    string ConnectString = "PROVIDER=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=" + 
    Server.MapPath("~/App_Data/Database1.accdb") + "; Persist Security Info=False;" ;



    Friday, March 22, 2013 4:39 AM
  • User81789783 posted

    I installed database engine (Compatible one)with same office version and its working fine and shine ...... (cheers :)

     

     

    Thanks

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 22, 2013 7:54 AM
  • User81789783 posted

    yes worked ..

    Friday, March 22, 2013 8:22 AM