Solved

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

Posted on 2010-09-16
5
524 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

808 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