Click here to Skip to main content
15,919,245 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi, please help me with this, After i deployed my project with installsheild whenever i tried to save a data it keeps saying 'operation must use an updatable query

What I have tried:

i have tried everything i can, please kindly help me out so i can finish the project on time
Posted
Updated 12-Sep-17 1:36am

1 solution

We can't help you - we don't have any access to your code!

At a guess, it's your connection string - did you update it for the new network the software is deployed on?

So start at the beginning. Probably you can't use the debugger - it's unlikely the target PC will have VS installed - so you will have to fall back on older methods, namely logging.
Add logging statements to your code to try and isolate which part of your software is generating the error. When you know the rough area, you can start adding more intense logging in that area to narrow it down further. At some point, the logging will need to include variable contents, string values such as connection strings and use input, and so forth. Each time you add more logging, you will need to reissue the new software to the target machine.

That should get you pointed in the right direction, or at least give you information you can feed to us.

Don't forget to remove the logging once you fixed the problem!
 
Share this answer
 
Comments
Member 13341316 12-Sep-17 7:43am    
Public Class Admission

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim conn As New OleDb.OleDbConnection
Dim connStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Buthdatabase.accdb;Persist Security Info=False"
Dim cmd As New OleDb.OleDbCommand

Try
conn.ConnectionString = connStr
conn.Open()
cmd.Connection = conn

cmd.CommandText = "INSERT INTO Admission ([Hospital No],[Patient's Name],[Date Attended],[Reffered By],[Consultant],[Ward],[Date Discharged],[Discharged To],[Condition On Discharge],[Discharge Summary]) " & _
"VALUES ([@HospitalNo],[@Patient'sName],[@DateAttended],[@RefferedBy],[@Consultant],[@Ward],[@DateDischarged],[@DischargedTo],[@ConditionOnDischarge],[@DischargeSummary]); "

cmd.Parameters.AddWithValue("@HospitalNo", Hospital_NoTextBox.Text)
cmd.Parameters.AddWithValue("@Patient'sName", Patient_s_NameTextBox.Text)
cmd.Parameters.AddWithValue("@DateAttended", DateTime.Text)
cmd.Parameters.AddWithValue("@RefferedBy", Reffered_ByTextBox.Text)
cmd.Parameters.AddWithValue("@Consultant", ConsultantTextBox.Text)
cmd.Parameters.AddWithValue("@Ward", WardTextBox.Text)
cmd.Parameters.AddWithValue("@DateDischarged", DateTime1.Text)
cmd.Parameters.AddWithValue("@DischargedTo", Discharged_ToTextBox.Text)
cmd.Parameters.AddWithValue("@ConditionOnDischarge", Condition_On_DischargeTextBox.Text)
cmd.Parameters.AddWithValue("@DischargeSummary", Discharge_SummaryTextBox.Text)


cmd.ExecuteNonQuery()
conn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
OriginalGriff 12-Sep-17 7:52am    
And what results do you get?
What does logging show you is happening?
Member 13341316 12-Sep-17 7:54am    
Operation must use an updateable query, that is what its showing
OriginalGriff 12-Sep-17 7:59am    
:sigh:
No, that's what your message is showing. It doesn't tell us what line is generating the error, or any of the variable contents.

I can't run your code: I don't have your data, I don't have your user inputs. You are going to have to do the donkey work here!

On a side note, why the heck are you passing Dates as strings? You aren't storing them as strings are you? That would be silly...
Richard Deeming 12-Sep-17 16:35pm    
The most common cause of that error is that the user doesn't have permission to write to the folder where the database is stored.

I see you're storing the database file in the application directory. Have you installed the application in a privileged location, like C:\Program Files\Your Application\ for example?

You'll need to install the database file in a folder which the user can write to - typically something under the user's profile, in the "application data" folder, or to the system-level "program data" folder.

Alternatively, ditch Access and upgrade to a proper multi-user DBMS - eg: SQL Server Express[^] or PostgreSQL[^]. But that's a much more complicated option.

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