-
Apr 1st, 2012, 11:54 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] 'field not updateable' OleDbException
Code:
Public Sub db_UpdateWorkHistory(ByVal WorkHistory_tablename As String, ByVal WorkHistory As DataSet)
Dim Conn As OleDbConnection
Dim SQL As String
Dim ConnectionString As String
SQL = "SELECT * FROM [" & WorkHistory_tablename & "] ORDER BY DateOfWork asc"
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & My.Settings.AppPath & "\" & gWorkingCentre & "Manager2011_Students.mdb"
Conn = New OleDbConnection(ConnectionString)
Dim da As New OleDbDataAdapter(SQL, Conn)
da.UpdateCommand = New OleDbCommand("UPDATE [" & WorkHistory_tablename & "] SET @ModuleName = ModuleName, Worksheet = @Worksheet, WorksheetID = @WorksheetID, NumQuestions = @NumQuestions, Tries = @Tries, TopicName = @TopicName, NumSheets = @NumSheets, Mistakes = @Mistakes, Percentage = @Percentage, Time_taken = @Time_taken, OralTopic = @OralTopic, OralErrors = @OralErrors, OralTime = @OralTime, Mastered = @Mastered, HomeComment = @HomeComment, InstructorNotes = @InstructorNotes, ParentStudentComment = @ParentStudentComment, InstructorComments = @InstructorComments WHERE DateOfWork = @DateOfWork")
da.UpdateCommand.Connection = Conn
da.UpdateCommand.Parameters.Add("@ModuleName", OleDbType.VarChar, 15, "ModuleName")
da.UpdateCommand.Parameters.Add("@Worksheet", OleDbType.VarChar, 150, "Worksheet")
da.UpdateCommand.Parameters.Add("@WorksheetID", OleDbType.Integer, 6, "WorksheetID")
etc. etc. etc......
Try
Conn.Open()
da.Update(WorkHistory)
WorkHistory.AcceptChanges()
da.Dispose()
Conn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message & " - " & ex.Source)
Conn.Close()
End Try
End Sub
The code above *was* working fine until I changed some code elsewhere (but I can't identify which of those changes might have produced this problem).
I am getting the "Field not updateable" error when da.Update(WorkHistory) is executed. The problem field is "ModuleName". The table isn't indexed on this field so that isn't the answer.
I've googled the error message but come up with nothing helpful. Can anyone shed some light here, please?
Paul Orton
VB6
Visual Web Developer 2008 Express Edition
Microsoft Visual Basic 2012 Express
-
Apr 1st, 2012, 12:08 PM
#2
-
Apr 1st, 2012, 12:21 PM
#3
Thread Starter
Fanatic Member
Re: 'field not updateable' OleDbException
Doh! What an idiot - I didn't bother checking the UpdateCommand because, as I said, the code had been working fine up to a few days ago and I don't recall making any change to it (but I must have done - and messed up badly!).
Thanks for spotting that!!
Paul Orton
VB6
Visual Web Developer 2008 Express Edition
Microsoft Visual Basic 2012 Express
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|