Oledb connecting updating Access table from Visual Studio

Posted on 2011-10-29
Last Modified: 2013-11-26
Hi Experts
I am trying to connect and Update Access 2007 Databse .accdb through Visual Studio 2010.
I manage to connect to it using the following code

 Dim connStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\PRICE_STRUCTURES\FORMULAS\MAIN_GROUP.accdb"
    Public con As New OleDb.OleDbConnection(connStr)

    Public Da As New System.Data.OleDb.OleDbDataAdapter
      Public DtSet As New System.Data.DataSet
        Da.Fill(DtSet, "Sheet1")
       dt = DtSet.Tables("Sheet1")
        DataGridView1.DataSource = dt

That works but when I try to update Access database using ____

        Dim cmd As New OleDbCommand
        If Not con.State = ConnectionState.Open Then
        End If
        cmd.Connection = con
        cmd.CommandText = "Update Main_Group.sheet1 set Main_group.selling1='43433' where Main_group.range='ADL1'"

It gives the error  main_group.mdf not fund.
I made the connection to Main_group.accdb    not .mdf

Please Help
Question by:b001
    LVL 12

    Accepted Solution

    Remove Main_group from query:

           Dim cmd As New OleDbCommand
            If Not con.State = ConnectionState.Open Then
            End If
            cmd.Connection = con
            cmd.CommandText = "Update sheet1 set selling1='43433' where range='ADL1'"


    Author Comment

    Hi  Mamtha1982:

    It gives me following error

    OleDbException was unhandled
    Operation must use an updateable query.

    Please help
    LVL 12

    Expert Comment

    Can you check your Access file has all the permissions to update the file?

    Follow following link:

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now