Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ado

Posted on 2001-06-04
10
Medium Priority
?
245 Views
Last Modified: 2013-11-23
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
0
Comment
Question by:kar_online
10 Comments
 
LVL 2

Expert Comment

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

Accepted Solution

by:
mukunth earned 200 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.
Cheers.
0
 
LVL 1

Expert Comment

by:mammouth
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
    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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Expert Comment

by:mammouth
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

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
 
LVL 54

Expert Comment

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

Expert Comment

by:Carraf
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)
   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
 
LVL 1

Expert Comment

by:mammouth
ID: 6153114
you could use adOpendynamic instead of adOpenKeyset
0
 
LVL 1

Expert Comment

by:Moondancer
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.
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
 
LVL 49

Expert Comment

by:DanRollins
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
0
 
LVL 1

Expert Comment

by:Computer101
ID: 7167854
Comment from expert accepted as answer

Computer101
E-E Moderator
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

927 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