-
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()
-
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()
-
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
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks