Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Access Databases

Access Databases

Scheduled Pinned Locked Moved Database
databasehelpquestioncsharp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QC_2000
    wrote on last edited by
    #1

    Hi, I'm writing a Windows application that's a front end interface for an Access database. I'm using VB.NET and I'm getting a very strange error when I try to edit a record in one of my tables. The error says: "5 - Cannot set 'Discrepancy'" Discrepancy is the column name. The strange thing is that the line of code that's raising the error is within a Try, Catch, End Try block but the error is raised without the code execution passing through the Catch part of the block! And even stranger than that, the new value that I'm setting to the 'Discrepancy' field is being set, even though the error message says that it can't set it!! I've checked, double-checked, and triple-checked all of the usual suspects (spelling, table mapping, schema, oleadapter configuration, etc) and everything seems fine. I can't for the life of me see what is wrong. Can anyone help please? I've included my code below. The line that's generating the error is the one with the EndEdit() method. I've also tried checking for errors on the line immediately before the EndEdit() method and there were none. Try Dim Record As DataRow = Me.dtsRent.Tables(0).Rows(Me.cmbWeek.SelectedIndex) Dim Balanced as String If CInt(Me.txtRentDisc.Text) = 0 Then Balanced = "Yes" Else Balanced = "No" Record.BeginEdit() Record.Item("Modified By") = Profile("Officer").ToString Record.Item("Date Modified") = DateTime.Now.ToString Record.Item("Reconciled") = Balanced Record.Item("Total Payments") = CDec(Me.txtRentPayments.Text) Record.Item("HBP19 Controls") = CDec(Me.txtRentHB19.Text) Record.Item("Discrepancy") = CDec(Me.txtRentDisc.Text) Record.EndEdit() Me.adpRent.Update(Me.dtsRent) Catch ex As Exception MsgBox(Err.Number & " - " & Err.Description) End Try Thanks in advance. QC

    R 1 Reply Last reply
    0
    • Q QC_2000

      Hi, I'm writing a Windows application that's a front end interface for an Access database. I'm using VB.NET and I'm getting a very strange error when I try to edit a record in one of my tables. The error says: "5 - Cannot set 'Discrepancy'" Discrepancy is the column name. The strange thing is that the line of code that's raising the error is within a Try, Catch, End Try block but the error is raised without the code execution passing through the Catch part of the block! And even stranger than that, the new value that I'm setting to the 'Discrepancy' field is being set, even though the error message says that it can't set it!! I've checked, double-checked, and triple-checked all of the usual suspects (spelling, table mapping, schema, oleadapter configuration, etc) and everything seems fine. I can't for the life of me see what is wrong. Can anyone help please? I've included my code below. The line that's generating the error is the one with the EndEdit() method. I've also tried checking for errors on the line immediately before the EndEdit() method and there were none. Try Dim Record As DataRow = Me.dtsRent.Tables(0).Rows(Me.cmbWeek.SelectedIndex) Dim Balanced as String If CInt(Me.txtRentDisc.Text) = 0 Then Balanced = "Yes" Else Balanced = "No" Record.BeginEdit() Record.Item("Modified By") = Profile("Officer").ToString Record.Item("Date Modified") = DateTime.Now.ToString Record.Item("Reconciled") = Balanced Record.Item("Total Payments") = CDec(Me.txtRentPayments.Text) Record.Item("HBP19 Controls") = CDec(Me.txtRentHB19.Text) Record.Item("Discrepancy") = CDec(Me.txtRentDisc.Text) Record.EndEdit() Me.adpRent.Update(Me.dtsRent) Catch ex As Exception MsgBox(Err.Number & " - " & Err.Description) End Try Thanks in advance. QC

      R Offline
      R Offline
      Rob Graham
      wrote on last edited by
      #2

      Try surrounding the field name with square brackets - "[Discrepancy]". Access has some weird keywords... We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest. Patricia Aburdene Bulls make money, bears make money, pigs get slaughtered. Jim Cramer

      Q 1 Reply Last reply
      0
      • R Rob Graham

        Try surrounding the field name with square brackets - "[Discrepancy]". Access has some weird keywords... We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest. Patricia Aburdene Bulls make money, bears make money, pigs get slaughtered. Jim Cramer

        Q Offline
        Q Offline
        QC_2000
        wrote on last edited by
        #3

        Thanks Rob, However, the field/column name is a string data type in VB. Including the square brackets in the string would make them part of the field/column name, rendering it unrecognisable (if that's a real word). Square brackets can only be used in an SQL command. QC -- modified at 11:59 Friday 28th April, 2006

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups