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


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

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

  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



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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center