I have an application written in VB that connects with ODBC to a Sybase-database. When 2 users want to update the same record, the changes of the first one got lost because the other user overwrite the changes. I assume I have to put locking on it. How can I do this?
Here is the code I use:
Here is the code I use:
VB.NET:
Option Explicit
Public WithEvents gCon As rdoConnection
Public rdoArticle As rdoResultset
Private Sub Form_Load()
Dim rdoArticle As rdoResultset
Dim SqlQuery As String
gCon = New rdoConnection
With gCon
.Connect = "uid=dba;pwd=sql;DSN=TestDB"
.CursorDriver = rdUseIfNeeded
.EstablishConnection(rdDriverNoPrompt)
End With
SqlQuery = "Select " _
& " * from Article " _
& " where ArticleId = 24"
rdoArticle = gCon.OpenResultset(SqlQuery, rdOpenKeyset, rdConcurReadOnly, _
rdAsyncEnable + rdExecDirect)
If rdoArticle.BOF = True Then
txtArtName = ""
Else
txtArtName = rdoArticle.rdoColumns("Artdescr")
End If
End Sub
Private Sub Save_Click()
Dim rdoArticle As rdoResultset
Dim SqlQuery As String
SqlQuery = "Update Article set ArtDescr = '" & txtArtName.Text & "'" _
& " where ArticleId = 24 "
rdoArticle = gCon.OpenResultset(SqlQuery, rdOpenKeyset, rdConcurReadOnly, _
rdAsyncEnable + rdExecDirect)
End Sub