Discussion Locked

error

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am working on a web application in vb.net:
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)("Account_Name") = 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

2 replies

by nnco00

here are the sql statement I am using, are there any fault in them?

'
'OleDbInsertCommand1
'
Me.OleDbInsertCommand1.CommandText = "INSERT INTO Accounts(Account_Name, Account_Reference, 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, "Account_Name"))
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 Account_Name, Account_Reference, ID, [Key], SubID FROM Accounts"
Me.OleDbSelectCommand1.Connection = Me.Cnn

'
'OleDbUpdateCommand1
'
Me.OleDbUpdateCommand1.CommandText = "UPDATE Accounts SET Account_Name = ?, Account_Reference = ?, ID = ?, SubID = ? WHERE ([Key] = ?) AND (Account_Name = ? OR ? IS NULL AND Account_Name IS NULL) AND (Account_Reference = ? OR ? IS NULL AND Account_Reference 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 ("Account_Name", System.Data.OleDb.OleDbType.VarWChar, 50, "Account_Name"))
Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Account_Reference", System.Data.OleDb.OleDbType.VarWChar, 12, "Account_Reference"))
Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("ID", System.Data.OleDb.OleDbType.VarWChar, 5, "ID"))
Me.OleDbUpdateCommand1.P

by mikenac

I am not very .net savvy, but in standard ADO, you must specify a different lockType (adLockType) for your recordset (the default is read-only). Something like:

Me.OleDbSelectCommand1.LockType = adLockOptimistic

See if that helps

This discussion is closed to new replies.