Solved

Rowset does not support fetching backward. MS Access 2007 and Javascript

Posted on 2010-09-16
5
521 Views
Last Modified: 2012-05-10
Experts,

So I have a Javascript function that I am using to connect to MS Access 2007 dynamically using HTML DOM. Whenever I reach the end of the record set and I move to the previous record, I get an error:

"Rowset does not support fetching backward." Please help fix it!
function fnLoad()	{ 
  strConnect = "DSN=QTPDSN";
  oConn = new ActiveXObject("ADODB.Connection");
  oConn.Open(strConnect);
  rs.CursorType = adOpenDynamic;
  rs.LockType = adLockPessimistic;
  rs.CursorLocation = adUseClient;
  rs=oConn.Execute("SELECT * from PolicyInfo where RCApplied = '" + gRCApplied + "'");
  rs.MoveLast; 
}

Open in new window

0
Comment
Question by:DoofuS
  • 4
5 Comments
 
LVL 11

Accepted Solution

by:
datAdrenaline earned 500 total points
ID: 33698199
The recordset that .Execute returns will only be read-only with a forward-only cursor.  You will want to use the .Open method of the Recordset object, then you will be able to control the .CursorType etc. (like you are attempting to do) in order to get the ability to traverse forward and backward.

PS> Why the .MoveLast?
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 33698242
Example line of code (note I am not a Java programmer .. so cut some slack please :) :

function fnLoad()      {
  strConnect = "DSN=QTPDSN";
  oConn = new ActiveXObject("ADODB.Connection");
  rs = new ActiveXObject("ADODB.Recordset");
  oConn.Open(strConnect);
  rs.ActiveConnectio = oConn;
  rs.CursorType = adOpenDynamic;
  rs.LockType = adLockPessimistic;
  rs.CursorLocation = adUseClient;
  rs.Source = "SELECT * from PolicyInfo where RCApplied = '" + gRCApplied + "'";
  rs.Open;
  rs.MoveLast;
}

Also, note that you can pass several arguments in the .Open method ... here is the prototype for the .Open method:

recordset.Open Source, ActiveConnection, CursorType, LockType, Options

More info can be found here:
http://msdn.microsoft.com/en-us/library/ms675544(VS.85).aspx
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 33698251
This ...
rs.ActiveConnectio = oConn

Should be ...
rs.ActiveConnection = oConn

That "Air Code" debugger is not so good at catching typos! :)
0
 

Author Closing Comment

by:DoofuS
ID: 33864320
Sorry for accepting your answer late...got caught up. Thanks
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 33886115
Your welcome! .. Thank you for following up.  Good luck with your project!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses four methods for overlaying images in a container on a web page
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now