Community discussion forum

Cannot Update Boolean Status in MS Access. ERROR "Data type mismatch in criteria expression"

  • 3 months ago

    Im newbie in VB.net having problem in update problem. Hope someone can help.

    This is my code.

        Private Sub updateStatus()
            Dim lst As Integer = vcd_id_ListBox.Items.Count
            Dim j As Integer = 0
            Dim dbCommand As New OleDbCommand
            Dim strBoolean, z
            strBoolean = "false"
            z = CBool(strBoolean)
            Do While j <= lst - 1
                dbCommand.CommandText = "Update VCDTable Set " _
                & "vStatus='" & z & "' " _
                & "WHERE VCDID=" & vcd_id_ListBox.Items(j)

                dbCommand.Connection = con
                dbCommand.Connection.Open()
                dbCommand.ExecuteNonQuery()
                con.Close()
                j += 1
                MsgBox("Updated")
            Loop

        End Sub

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 3 months ago

    Hi, You have to update -1 (For True) 0 (For False) dbCommand.CommandText = "Update VCDTable Set " _ & "vStatus=0 " _ & "WHERE VCDID=" & vcd_id_ListBox.Items(j) Regards Veena

  • 3 months ago

    yeah~ everything woking fine now... thanks for helping me !

    love VB so much haha~~ 

Post a reply

Enter your message below

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