Concurrency violation question


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Concurrency violation question

  1. #1
    Jeff Johnson Guest

    Concurrency violation question


    "An unhandled exception of type 'System.Data.DBConcurrencyException' occurred
    in system.data.dll

    "Additional information: Concurrency violation: the UpdateCommand affected
    0 records."

    ***

    Dim ds As New DataSet()
    Dim da As OdbcDataAdapter

    da = DataAdapter("tblCTHeader", "CashTicketID", 1, True)
    _conn.Open()

    da.Fill(ds, "tblCTHeader")

    MsgBox(ds.Tables("tblCTHeader").Rows(0)("MyLock"))
    ds.Tables("tblCTHeader").Rows(0)("MyLock") = 5000
    da.Update(ds.Tables("tblCTHeader"))

    _conn.Close()

  2. #2
    Jeff Johnson Guest

    Re: Concurrency violation question


    Oops. (I hit "tab" and then "space" a couple of times... triggering the post.)

    Anyway... the code fails on the Update method. I don't see why it should.

    Any ideas?



    "Jeff Johnson" <jeff.johnson@nospam.com> wrote:
    >
    >"An unhandled exception of type 'System.Data.DBConcurrencyException' occurred
    >in system.data.dll
    >
    >"Additional information: Concurrency violation: the UpdateCommand affected
    >0 records."
    >
    >***
    >
    >Dim ds As New DataSet()
    > Dim da As OdbcDataAdapter
    >
    > da = DataAdapter("tblCTHeader", "CashTicketID", 1, True)
    > _conn.Open()
    >
    > da.Fill(ds, "tblCTHeader")
    >
    > MsgBox(ds.Tables("tblCTHeader").Rows(0)("MyLock"))
    > ds.Tables("tblCTHeader").Rows(0)("MyLock") = 5000
    > da.Update(ds.Tables("tblCTHeader"))
    >
    > _conn.Close()



  3. #3
    Jeff Johnson Guest

    Re: Concurrency violation question



    This is my Dataadapter function I'm using...

    Public Function DataAdapter(ByVal TableName As String, ByVal KeyName As String,
    ByVal ID As Integer, Optional ByVal MakeCommands As Boolean = False) As OdbcDataAdapter
    Dim s As New StringBuilder()
    If MakeCommands Then
    s.Append("SELECT * FROM ").Append(TableName).Append(" WHERE ").Append(KeyName).Append("=
    ").Append(ID)
    Else
    s.Append("SELECT * FROM ").Append(TableName).Append(" WHERE ").Append(KeyName).Append("=
    ").Append(ID)
    End If
    Dim da As New OdbcDataAdapter(s.ToString, _conn)
    If MakeCommands Then Dim cb As New OdbcCommandBuilder(da)
    Return da
    End Function

  4. #4
    Jeff Johnson Guest

    Re: Concurrency violation question


    Dim ds As New DataSet()
    Dim da As OdbcDataAdapter

    da = DataAdapter("TestTable", "TestID", 2, True)
    _conn.Open()

    da.Fill(ds, "TestTable")

    MsgBox(ds.Tables("TestTable").Rows(0)("MyInteger"))
    ds.Tables("TestTable").Rows(0)("MyInteger") = 5000
    da.Update(ds.Tables("TestTable"))

    _conn.Close()


    I tried the code with just a simple table instead (AutoIncrement field and
    an integer.) It works fine....

    So the codes fine... It must be something wrong with the database or the
    table.

    MySQL and the ODBC driver chokes on Empty Strings.... I'm trying some other
    tables with other values & fields to see if I can recreate the problem....


    Sorry about the 4-5 posts... a lot of problems get solved just when you're
    trying to explain it to someone. Maybe it will work that way this time!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center