[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Oledb connecting updating Access table from Visual Studio

Posted on 2011-10-29
3
Medium Priority
?
675 Views
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
 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
0
Comment
Question by:b001
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
Praveen Kumar earned 2000 total points
ID: 37055187
Remove Main_group from query:


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

0
 

Author Comment

by:b001
ID: 37055878
Hi  Mamtha1982:

It gives me following error

OleDbException was unhandled
Operation must use an updateable query.

Please help
0
 
LVL 12

Expert Comment

by:Praveen Kumar
ID: 37056053
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
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month19 days, 22 hours left to enroll

873 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