error in update

asp.net United States
  • 18 years ago

    Why am I getting “Operation must use an updateable querry” error message at the: da.update statement of the following sub:


    Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click


    DS.Tables("accounts").Rows(Pos).BeginEdit()
    DS.Tables("accounts").Rows(Pos)("ID") = txtID.Text
    DS.Tables("accounts").Rows(Pos)("AccountName") = txtName.Text
    DS.Tables("accounts").Rows(Pos)("Account
    Reference") = txtReference.Text
    DS.Tables("accounts").Rows(Pos)("SubID") = txtSub.Text
    DS.Tables("accounts").Rows(Pos).EndEdit()


    DA.Update(DS, "Accounts")


    End Sub


    The sql statements I am using are the following:


    '
    'OleDbInsertCommand1
    '
    Me.OleDbInsertCommand1.CommandText = "INSERT INTO Accounts(AccountName, AccountReference, ID, SubID) VALUES (@Name, @Ref, @ID, @Sub);"
    Me.OleDbInsertCommand1.Connection = Me.Cnn
    Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("@Name", System.Data.OleDb.OleDbType.VarWChar, 50, "AccountName"))
    Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("@Reference", System.Data.OleDb.OleDbType.VarWChar, 12, "Account
    Reference"))
    Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("@ID", System.Data.OleDb.OleDbType.VarWChar, 5, "ID"))
    Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("@SubID", System.Data.OleDb.OleDbType.VarWChar, 5, "SubID"))


    '
    'OleDbSelectCommand1
    '
    Me.OleDbSelectCommand1.CommandText = "SELECT AccountName, AccountReference, ID, [Key], SubID FROM Accounts"
    Me.OleDbSelectCommand1.Connection = Me.Cnn


    '
    'OleDbUpdateCommand1
    '
    Me.OleDbUpdateCommand1.CommandText = "UPDATE Accounts SET AccountName = ?, AccountReference = ?, ID = ?, SubID = ? WHERE ([Key] = ?) AND (AccountName = ? OR ? IS NULL AND AccountName IS NULL) AND (AccountReference = ? OR ? IS NULL AND AccountReference IS NULL) AND (ID = ? OR ? IS NULL AND ID IS NULL) AND (SubID = ? OR ? IS NULL AND SubID IS NULL)"
    Me.OleDbUpdateCommand1.Connection = Me.Cnn
    Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter ("AccountName", System.Data.OleDb.OleDbType.VarWChar, 50, "AccountName"))
    Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("AccountReference", System.Data.OleDb.OleDbType.VarWChar, 12, "AccountReference"))
    Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("ID", System.Data.OleDb.OleDbType.VarWChar, 5, "ID"))
    Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("SubID", System.Data.OleDb.OleDbType.VarWChar, 5, "SubID"))
    Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter ("OriginalKey", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(10, Byte), CType(0, Byte), "Key", System.Data.DataRowVersion.Original, Nothing))
    Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original
    AccountName", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "AccountName", System.Data.DataRowVersion.Original, Nothing))
    Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("OriginalAccountName1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "AccountName", System.Data.DataRowVersion.Original, Nothing))
    Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original
    AccountReference", System.Data.OleDb.OleDbType.VarWChar, 12, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "AccountReference", System.Data.DataRowVersion.Original, Nothing))
    Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("OriginalAccountReference1", System.Data.OleDb.OleDbType.VarWChar, 12, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "AccountReference", System.Data.DataRowVersion.Original, Nothing))
    Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original
    ID", System.Data.OleDb.OleDbType.VarWChar, 5, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Original, Nothing))
    Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("OriginalID1", System.Data.OleDb.OleDbType.VarWChar, 5, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Original, Nothing))
    Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original
    SubID", System.Data.OleDb.OleDbType.VarWChar, 5, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "SubID", System.Data.DataRowVersion.Original, Nothing))
    Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_SubID1", System.Data.OleDb.OleDbType.VarWChar, 5, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "SubID", System.Data.DataRowVersion.Original, Nothing))

  • 18 years ago

    the error "Operation must use an Updateable query" generally means that the database permissons are not correctly set.


    Heres how to reproduce the issue on your own system.


    Try opening any Access file on vai the trusty Windoze Explorer.... now after access has openned your DB switch back to Windoze Explorer.. notice it created a *.ldb file? well thtas what your servers trying to do but it cant because theres obviously no write permissons on that folder.


    Contact your admin about it if your not sure how to do this.


    Hope that helps!

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The generation of random numbers is too important to be left to chance.” - Robert R. Coveyou