Link to home
Start Free TrialLog in
Avatar of b001
b001Flag for Afghanistan

asked on

Oledb connecting updating Access table from Visual Studio

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
 con.Open()
        Da.Fill(DtSet, "Sheet1")
       dt = DtSet.Tables("Sheet1")
        DataGridView1.DataSource = dt
        con.Close()

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


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

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

Please Help
Thanks
ASKER CERTIFIED SOLUTION
Avatar of Praveen Kumar
Praveen Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of b001

ASKER

Hi  Mamtha1982:

It gives me following error

OleDbException was unhandled
Operation must use an updateable query.

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

Follow following link:
http://support.yessoftware.com/kb_article.asp?article_id=72