DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Ken Guest

    How to check if the record exists in the current ado recordset?


    Hi All,
    I want to check if the record exists in the ado recordset or not. I tried
    to use the ado.seek function, but it is not work well for me. Can any one
    give me a suggestion?


    Thanks,
    Ken

  2. #2
    Jim Guest

    Re: How to check if the record exists in the current ado recordset?


    "Ken" <kenchk@sympatico.ca> wrote:
    >
    >Hi All,
    >I want to check if the record exists in the ado recordset or not. I tried
    >to use the ado.seek function, but it is not work well for me. Can any one
    >give me a suggestion?
    >
    >
    >Thanks,
    >Ken


    '**************************************
    This isn't the greatest way but it works.

    dim the variables you have to use.

    After you open the connection to the databse do this. You might have to
    open the connection twice. Close the first before opening the second.
    Hope this helps.

    '******************************************************
    '*** Check to see how many exist with current info. ***
    '******************************************************
    sSql = "SELECT * FROM Table "
    sSql = sSql & "WHERE RecordType = '" & txtbox.Text & "' "
    sSql = sSql & "AND Account = '" & txtbox.Text & "' "
    sSql = sSql & "AND Cusip = '" & txtbox.Text & "' "
    sSql = sSql & "AND TransCode = '" & txtbox.Text & "'"

    rs.Open sSql, Conn, adOpenKeyset, adLockPessimistic

    '***************************************************************
    '*** This will Count how many record fit the criteria above. ***
    '***************************************************************
    Do While Not rs.EOF

    iCount = iCount + 1
    rs.MoveNext

    Loop

  3. #3
    Ken Guest

    Re: How to check if the record exists in the current ado recordset?


    Thanks,
    Ken

    "Jim" <jcb1269@excite.com> wrote:
    >
    >"Ken" <kenchk@sympatico.ca> wrote:
    >>
    >>Hi All,
    >>I want to check if the record exists in the ado recordset or not. I tried
    >>to use the ado.seek function, but it is not work well for me. Can any one
    >>give me a suggestion?
    >>
    >>
    >>Thanks,
    >>Ken

    >
    >'**************************************
    >This isn't the greatest way but it works.
    >
    >dim the variables you have to use.
    >
    >After you open the connection to the databse do this. You might have to
    >open the connection twice. Close the first before opening the second.
    >Hope this helps.
    >
    >'******************************************************
    >'*** Check to see how many exist with current info. ***
    >'******************************************************
    >sSql = "SELECT * FROM Table "
    >sSql = sSql & "WHERE RecordType = '" & txtbox.Text & "' "
    >sSql = sSql & "AND Account = '" & txtbox.Text & "' "
    >sSql = sSql & "AND Cusip = '" & txtbox.Text & "' "
    >sSql = sSql & "AND TransCode = '" & txtbox.Text & "'"
    >
    >rs.Open sSql, Conn, adOpenKeyset, adLockPessimistic
    >
    >'***************************************************************
    >'*** This will Count how many record fit the criteria above. ***
    >'***************************************************************
    >Do While Not rs.EOF
    >
    > iCount = iCount + 1
    > rs.MoveNext
    >
    >Loop



Bookmarks

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


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


Sponsored Links