ACcESS 2007 connection string ????

Discussion in 'Databases' started by Draco2032, Aug 17, 2010.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Let me start by saying that this is my first time working with ACCESS in a ASP .NET website using C#. I have only done it with SQL 2008.
    In SQL 2008 when you create a new data source after adding your database, it automatically generates a connection string for you. Apparently this is not true with an ACCESS data base. Am using VS 2010, and I can display the content of the data base in a data grid but i cannot add edit or delete for that matter any record.

    The error for sure is in the connection string part, and i would appreciate if someone would guide me to the right direction here.

    Code:
     protected void btnSendRev_Click(object sender, EventArgs e)
        {
            OleDbConnection cnn = new OleDbConnection("_database/LARMDAT.accdb");
            OleDbCommand cmm = new OleDbCommand ("INSERT INTO Reviews(ID,Name_,Comment,[Would you Recommend to a firend?])" +
                "Values(@D,@N,@C,@WU)",cnn);
            cmm.Parameters.Add("@D", System.Data.OleDb.OleDbType.Date);
            cmm.Parameters["@D"].Value = DateTime.Now.ToString();
    
            cmm.Parameters.Add("@N", System.Data.OleDb.OleDbType.VarChar);
            cmm.Parameters["@N"].Value = txtName.Text;
    
            cmm.Parameters.Add("@WU", System.Data.OleDb.OleDbType.Binary);
            cmm.Parameters["@WU"].Value = chkYes.Text;
            cnn.Open();
            cmm.ExecuteNonQuery();
            cnn.Close();
    
        }
    
    Many total thanks in advance and have a nice day.
     
  2. Hi,
    Far as I know the 2010 version of Access can only currently be used in Azure hosting.
    I have not been able to get it to work with ASP.NET at all on-line.
    The only way I've been able to do this is to downgrade the DB to previous versions.
    All the best,
    Mark
     
  3. Actually is ACCESS 2007 what am using and i fix the problem with the connection string, now the problem is with the
    "cmm. Executenonquery();"
    command here is an update of my code;
     
  4. ...I should have just said the .accdb extension version.
    That's what I don't think will work.
     
  5. Thanks for you help Wisemx, but so what you mean i have to use a older version of access?
    How far back do i have to go? 2003? And sorry for not thanking you before, i appreciate your help a lot.
     
  6. I finally got the error! I was missing a parameter to fill the database, i thought i would post the answer for anyone that runs into the same problem.
    I have not uploaded it to the server, but it works in the debugger, here it is the complete code.


     
  7. If you get that working on the server please let me know.
    I can get that format to work locally but not on the server.
     
  8. Yes it worked! It is working, people already used it and it works.

    http://www.larocketmovers.com/Reviews.aspx

    All that is pure access 2007 with the behind code given above. you need to put the database in a _database folder for it to work perfectly.

    Am using VS 2010 with .Net framework 4.0

    feel free to leave a review. The webpage still needs some work, but i needed to upload it as soon as possible. I'll work with validations later on this week.
     
  9. Good job.
    I need to play with this some more.
    The way you got it to work with OLEDB wasn't on my list while trying, I was using the VS AccessDataSource which only works locally for me when using the new formats.
    All the best,
    Mark
     
  10. Update: Didn't know this until just now, duh. ;-)
    The AccessDataSource only works with the Access MBD format. Did not know that.
    What I was able to do just now was replace it with a SqlDataSource and set the conn string so it was using the correct format:
    Doing it that way your newer format Access DB can be placed in the ASP.NET App_Data folder.
    All the best,
    Mark
     
  11. Problem with connection on the website

    I have created a website using visual web developer 2008 express edition and connected it with MS Access database. The site is running fine on my local computer but on Internet I am not able to connect to the database (Nwind.mdb). This website is in a subdirectory called MySecondWebsite. Kindly help me to connect to the database.
     
  12. ...I can help, just need a bit more info.
    How are you doing it so far?
    For example, a single page that has an ASP.NET control connected to an Access DB, etc.
    I just need an idea of how you want to do this.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page