Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im a beginner and having a hard time on searching for a solution.Im using vb.net and ms access as database. Here is my problem

The SQL works fine when i debug in the project, but once i make the setup and install it shows the error?
operation must use an updateable


Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
DateTimePicker1.Refresh()
DateTimePicker1.Value = DateTime.Now
DATEANDTIMEtxt.Text = CType(DateTimePicker1.Value, String)

If TextBox4.Text = "" Or TextBox5.Text = "" Then
MsgBox("plz fill the info")
Else

Try
Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\DB_HR.accdb;Jet OLEDB:DATABASE PASSWORD=dbhr123;")

Dim Str As String = "Insert Into LOGIN([YOUR_NAME],[PASSWORD],[DATEANDTIME]) Values (?,?,?)"
Dim cmd As New OleDbCommand(Str, conn)
cmd.Parameters.Add(New OleDbParameter("YOUR_NAME", CType(TextBox4.Text, String)))
cmd.Parameters.Add(New OleDbParameter("PASSWORD", CType(TextBox5.Text, String)))
cmd.Parameters.Add(New OleDbParameter("DATEANDTIME", CType(DATEANDTIMEtxt.Text, String)))
conn.Open()
cmd.ExecuteNonQuery() '<------Error say's it was here
MsgBox("Create success")
conn.Close()
Panel1.Visible = False
TextBox4.Clear()
TextBox5.Clear()
TextBox4.Select()

TextBox1.Enabled = True
TextBox2.Enabled = True
Button1.Enabled = True
Button2.Enabled = True
TextBox1.Text = ""
TextBox1.Select()

Catch ex As Exception
MsgBox(ex.ToString())
End Try
End If
End Sub


this is the error

System.Data.Oledb.OledbExeption (0x80004005): Operation must use an updateable query.
at WindowsApp1.Form1.Button4_Click(Object sender, EventArgs e) in C:\Users\Alex\Desktop\HR_appP2 w password\WindowsApp1\WindowsApp1\Form1.vb:line 112

What I have tried:

I have already try the this
I change my application in Administrator Privilege
Change Level From

<requestedExecutionLevel  level="asInvoker" uiAccess="false" />

To

<requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />

I have checked the permissions on the folder that contains the Access file.


Is it the way how I build it?
Posted
Updated 11-Jul-18 15:51pm
v3
Comments
Dave Kreskowiak 11-Jul-18 21:01pm    
Without seeing the code that creates the query and executes it, it's impossible to tell you what you did wrong.

Also, if you put your Access database in the same folder as your executable, under Program Files, that folder is going to be read only for all normal users. You have to move your Access database to a more appropriate folder, such as under C:\ProgramData\SomeFolder.
Jamim 11-Jul-18 21:23pm    
Thanks for suggesting to post the code. I already post the code
Jochen Arndt 12-Jul-18 6:58am    
It is very probable a privilege problem. While executing the application as admistrator will work in most cases, it is not recommended.

Instead use a directory where the user executing the application has write access like suggested by Dave.

If the database file exists already (e.g. when copying a template or an empty database upon installation), ensure also that the file itself has similar access rules (is writeable by the user(s)).
RedDk 13-Jul-18 13:40pm    
0x80004005 -> If you look here:
https://www.google.com/search?q=System.Data.OleDb.OleDbException+(0x80004005)+site:social.msdn.microsoft.com&num=100&sa=X&ved=0ahUKEwjn5vXAzpzcAhWBrZQKHbuDDX4QrQIIMygEMAA&biw=975&bih=886

... you'll see that this error is less descriptive of an actual breakdown in the code you're pushing through OleDb and more of a generic failure (on the part of OleDb dev's as MS, right?) ... and at best should be flagged as the lip of some cascading nonsense. I'm not going to scroll through the types of errors myself. I'll let you do it. Good luck.
Jamim 17-Jul-18 3:13am    
I already solve this i just forgot to look for the App.Config Thanks anyway ^_^. As a beginner we really appreciate expert help's also the article,links and others they gave

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900