dcsimg
Results 1 to 3 of 3
  1. #1

    Thread Starter
    Fanatic Member paulorton's Avatar
    Join Date
    Aug 2006
    Location
    West Wales
    Posts
    809

    Resolved [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

  2. #2
    Hyperactive Member jp26198926's Avatar
    Join Date
    Sep 2008
    Location
    General Santos City, Philippines
    Posts
    310

    Re: 'field not updateable' OleDbException

    how about if you change this

    @ModuleName = ModuleName

    to

    ModuleName = @ModuleName

    are u still getting the same error?
    "More Heads are Better than One"

  3. #3

    Thread Starter
    Fanatic Member paulorton's Avatar
    Join Date
    Aug 2006
    Location
    West Wales
    Posts
    809

    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
  •  



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.