Locking problem on table with RDO

epasman

Member
Joined
Nov 17, 2008
Messages
6
Programming Experience
5-10
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:

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
 
Given that this entire website is dedicated to VB.NET, I'd recommend you pose your question to the VB6 forum on CodeGuru.com; the support and activity there is excellent.
 

Latest posts

Back
Top