ado

hi,

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
kar_onlineAsked:
Who is Participating?
 
mukunthConnect With a Mentor Commented:
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.
Cheers.
0
 
BobbyOwensCommented:
What are you connecting to? (e.g. SQL Server, Access)
What are the properties of your connection and recordset?
0
 
mammouthCommented:
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
    ArrayRs=Rs.GetRows
Rs.Close
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
Next

0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
mammouthCommented:
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

userid=0
username=1

row is the result row

ex.:

if the result is

userid name
______ ____
1      John
5      Paul

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



0
 
Ryan ChongCommented:
Hi, check the EOF status.
0
 
CarrafCommented:
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)
   RecSet.Close
   Set RecSet = Nothing
Else....

' 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
      RecSet.MoveLast
      RecCount = RecNum
      Exit Function
   Case 2
      RecSet.MoveFirst
      RecCount = 1
      Exit Function
   Case Else
      RecSet.MoveFirst
      For i = 1 to RecCount - 1
         RecSet.MoveNext
      Next i
      RecCount = RecCount - 1
      Exit Function  
End Select

End Function

 





0
 
mammouthCommented:
you could use adOpendynamic instead of adOpenKeyset
0
 
MoondancerCommented:
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.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

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.
http://www.experts-exchange.com/questions/Q.11755918.html
http://www.experts-exchange.com/questions/Q.20003264.html
http://www.experts-exchange.com/questions/Q.20008258.html
http://www.experts-exchange.com/questions/Q.20014153.html
http://www.experts-exchange.com/questions/Q.20017971.html
http://www.experts-exchange.com/questions/Q.20099640.html
http://www.experts-exchange.com/questions/Q.20107573.html
http://www.experts-exchange.com/questions/Q.20113204.html
http://www.experts-exchange.com/questions/Q.20113209.html
http://www.experts-exchange.com/questions/Q.20129388.html
http://www.experts-exchange.com/questions/Q.20242818.html
http://www.experts-exchange.com/questions/Q.20256282.html

To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20107620.html
http://www.experts-exchange.com/questions/Q.12049959.html

*****  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
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643 
------> POINTS FOR EXPERTS awaiting comments are listed in the links below
http://www.experts-exchange.com/commspt/Q.20277028.html (Part 1)
http://www.experts-exchange.com/jsp/qShow.jsp?ta=commspt&qid=20295853 (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.
Moondancer
Moderator @ Experts Exchange
0
 
DanRollinsCommented:
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
0
 
Computer101Commented:
Comment from expert accepted as answer

Computer101
E-E Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.