Posted on 2001-06-04
Last Modified: 2013-11-23

i am usin ado.With all typres of cursors it says rs.moveprevious says not allowed.

Set rs = conn.Execute("select * from customer", adOpenKeyset)

help me
Question by:kar_online

Expert Comment

ID: 6152100
What are you connecting to? (e.g. SQL Server, Access)
What are the properties of your connection and recordset?

Accepted Solution

mukunth earned 50 total points
ID: 6152104
The Execute method of the connection object returns a forward-only recordset.Use the above as:

rs.Open "select * from customer",adOpenKeySet

It will work as you want it to.

Expert Comment

ID: 6152109
Use this is faster and you can movelast

Dim ArrayRs()
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
    Rs.Open "select * from customer, Conn, OpenForwardOnly, adLockReadOnly
Set Rs = Nothing

This will make a 2d array

to get the first row and first col:var=ArrayRs(0,0)
to get the second row and first col:var=ArrayRs(0,1)
to get the third row and first col:var=ArrayRs(0,2)

to get the first row and second col:var=ArrayRs(1,0)
to get the second row and second col:var=ArrayRs(1,1)

To get number of row return:var=Ubound(ArrayRs,2)

Whit .GetRows You can move forward and backward by change the index of ArrayRs(?,?)

You can do something like this

For i=0 to Ubound(ArrayRs,2)
     debug.print ArrayRs(0,i) 'this will print all result for the first field of the table

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.


Expert Comment

ID: 6152117
Comment to my last comment:

When i write
to get the first row and first col:var=ArrayRs(0,0)

col is the field number of your select

ex.:select userid, username


row is the result row


if the result is

userid name
______ ____
1      John
5      Paul

Row #1 is UserId# 1
Row #1 is UserId# 5

LVL 50

Expert Comment

by:Ryan Chong
ID: 6152201
Hi, check the EOF status.

Expert Comment

ID: 6152978
The problem could be related to your database ( I've had problems using .update and .delete when connecting to an AS/400 database). But try the follwing 2 things and see if either works (second solution will be slower!)

' Initialise
Dim RecSet As ADODB.Recordset
Set RecSet As New ADODB.Recordset  

'Open for dynamic read only navigation
RecSet.Open "Select * from customer", conn, adOpenDynamic, adLockReadOnly, adCmdText

'Check recordset contains something
If RecSet.EOF Then
   MsgBox("No records exist", vbOkOnly + vbInformation)
   Set RecSet = Nothing

' If .MovePrevious doesn't work here then try the following

' initialise integers
Dim RecCount as Integer
Dim RecNum as Integer

' store number of records in set
RecNum = RecSet.RecordCount

'store current record in set
RecCount = 1

'Use procedure to simulate MovePrevious
Call MovePrevious(RecSet,RecCount,RecNum)

'write procedure to simulate MovePrevious
Public Function MovePrevious(RecSet as ADODB.RecordSet,
                             RecCount as Integer,
                             RecNum as Integer)
Dim i as Integer

Select Case RecCount
   Case 1
      RecCount = RecNum
      Exit Function
   Case 2
      RecCount = 1
      Exit Function
   Case Else
      For i = 1 to RecCount - 1
      Next i
      RecCount = RecCount - 1
      Exit Function  
End Select

End Function



Expert Comment

ID: 6153114
you could use adOpendynamic instead of adOpenKeyset

Expert Comment

ID: 7025062
You have 14 open questions today that need your attention.  ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101, Netminder, Mindphaser or I will return to finalize these as soon as possible if after 7 days no response by the Asker.  EXPERTS-->  please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.

To view your locked questions, please click the following link(s) and evaluate the proposed answer.

*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link 
------> POINTS FOR EXPERTS awaiting comments are listed in the links below (Part 1) (Part 2)
Moderators will finalize this question if in @7 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
Thanks everyone.
Moderator @ Experts Exchange
LVL 49

Expert Comment

ID: 7132859
Hi kar_online,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Accept mukunth's comment(s) as an answer.

kar_online, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with my recommendation, please post an explanatory comment.
DanRollins -- EE database cleanup volunteer

Expert Comment

ID: 7167854
Comment from expert accepted as answer

E-E Moderator

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question