-
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.
-
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
-
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
-
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
Forum Rules
|
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
|
Bookmarks