CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Posts
    1

    Locking problem on table with RDO

    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:

    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

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Locking problem on table with RDO

    Please edit your post to properly use code tags, it is nearly impossible to read. If you have forgotten how, go back and re-read the "Before you post" faq at the top of the forums thread list [or just look in my signature below]
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Jan 2006
    Location
    Pearl of the orient
    Posts
    304

    Re: Locking problem on table with RDO

    Does the two updates occurs at the same time? I am not familiar with Sybase but it may probably is its method of concurrency control. Or that the criteria in the 2nd update is not already valid hence it cannot be persisted?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured