select data from view


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: select data from view

  1. #1
    VAX Guest

    select data from view


    I have a problem which is:
    When I execute the following code, the Recordcount will be -1.

    Anyone can help me to solve this problem?
    Thank you very much.

    code:

    dim cn as new adodb.connection
    dim rs as new adodb.recordset

    rs.open "select temp.name, test_view.no, test_view.dept " _
    & "from test_view, temp " _
    & "where temp.no = test_view.no",cn, adOpenKeyset, adLockBatchOptimistic

    "test_view" is a view and "temp" is a table.

  2. #2
    jy Guest

    Re: select data from view


    "VAX" <dunga0@yahoo.com> wrote:
    >
    >I have a problem which is:
    >When I execute the following code, the Recordcount will be -1.
    >
    >Anyone can help me to solve this problem?
    >Thank you very much.
    >
    >code:
    >
    >dim cn as new adodb.connection
    >dim rs as new adodb.recordset
    >
    >rs.open "select temp.name, test_view.no, test_view.dept " _
    > & "from test_view, temp " _
    > & "where temp.no = test_view.no",cn, adOpenKeyset, adLockBatchOptimistic
    >
    >"test_view" is a view and "temp" is a table.

    the easiest way to get an accurate recordcount is to use a client-side cursor:

    rs.cursorlocation=adUseClient
    rs.cursortype=adOpenStatic (no choice in this)
    rs.locktype=adLockBatchOptimistic (or adLockReadOnly if you don't need to
    update the recordset)
    rs.open ...

    this also gives you the option of disconnecting the recordset:
    set rs.activeconnection=nothing

  3. #3
    VAX Guest

    Re: select data from view


    Could you tell me what is the meaning of cursorlocation and cursortype?

    It is work now, thank you very much.


    "jy" <jy@directdialog.com> wrote:
    >
    >"VAX" <dunga0@yahoo.com> wrote:
    >>
    >>I have a problem which is:
    >>When I execute the following code, the Recordcount will be -1.
    >>
    >>Anyone can help me to solve this problem?
    >>Thank you very much.
    >>
    >>code:
    >>
    >>dim cn as new adodb.connection
    >>dim rs as new adodb.recordset
    >>
    >>rs.open "select temp.name, test_view.no, test_view.dept " _
    >> & "from test_view, temp " _
    >> & "where temp.no = test_view.no",cn, adOpenKeyset, adLockBatchOptimistic
    >>
    >>"test_view" is a view and "temp" is a table.

    >the easiest way to get an accurate recordcount is to use a client-side cursor:
    >
    >rs.cursorlocation=adUseClient
    >rs.cursortype=adOpenStatic (no choice in this)
    >rs.locktype=adLockBatchOptimistic (or adLockReadOnly if you don't need to
    >update the recordset)
    >rs.open ...
    >
    >this also gives you the option of disconnecting the recordset:
    >set rs.activeconnection=nothing



  4. #4
    Jman Guest

    Re: select data from view

    Do you need to know the exact record count or just is there's any record in
    the view?. In the second case, there's no need to check the Recordcount
    property. You can also check if the recordset position right after its been
    opened is both BOF and EOF at the same time.

    If this happens, it means the recordset is empty

    This would be

    rs.open "select temp.name, test_view.no, test_view.dept " _
    & "from test_view, temp " _
    & "where temp.no = test_view.no",cn, adOpenKeyset,
    adLockBatchOptimistic

    if not (rs.BOF and rs.EOF) then
    'Do something, as the recordset is not empty

    VAX escribi en mensaje <39d993ce$1@news.devx.com>...
    >
    >I have a problem which is:
    >When I execute the following code, the Recordcount will be -1.
    >
    >Anyone can help me to solve this problem?
    >Thank you very much.
    >
    >code:
    >
    >dim cn as new adodb.connection
    >dim rs as new adodb.recordset
    >
    >rs.open "select temp.name, test_view.no, test_view.dept " _
    > & "from test_view, temp " _
    > & "where temp.no = test_view.no",cn, adOpenKeyset,

    adLockBatchOptimistic
    >
    >"test_view" is a view and "temp" is a table.




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