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

x
?
Solved

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

Posted on 2010-09-16
5
Medium Priority
?
532 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 2000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

886 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