Solved

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

Posted on 2010-09-16
5
527 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

734 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