b001
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.OL EDB.12.0;D ata Source=C:\PRICE_STRUCTURES \FORMULAS\ MAIN_GROUP .accdb"
Public con As New OleDb.OleDbConnection(conn Str)
Public Da As New System.Data.OleDb.OleDbDat aAdapter
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
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.OL
Public con As New OleDb.OleDbConnection(conn
Public Da As New System.Data.OleDb.OleDbDat
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
Follow following link:
http://support.yessoftware.com/kb_article.asp?article_id=72
ASKER
It gives me following error
OleDbException was unhandled
Operation must use an updateable query.
Please help