PRB: Recordset DTC moveAbsolute Does Not Work With QueryString

ID: Q194024


The information in this article applies to:


SYMPTOMS

The Recordset DTC moveAbsolute method will not work when a query string variable is passed as the parameter (for example, rsDTC.moveAbsolute(4) vs rsDTC.moveAbsolute(number) where "number" is a Query String variable containing the number 4),


CAUSE

Query string varibles are by default a "string" datatype and the parameter passes to the moveAbsolute method must be an integer.


RESOLUTION

Convert the variable to an integer type and then pass it to the moveAbsolute method. In VBScript, you may use the cint function like this:


   number = cint(variable) 
Now you can pass "number" into the moveAbsolute method.

NOTE: This cannot be done in JScript or JavaScript because every variable is an Object in JScript and JavaScript does not have an applicable type for the moveAbsolute method.


STATUS

This behavior is by design.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new project in Visual InterDev 6.0.


  2. Make sure that the default script language is set to Server: VBScript and Client: JavaScript.


  3. Create a valid data connection for your project.


  4. Add a new Active Server Page (ASP) to the project.


  5. Drag a recordset DTC onto the ASP page between the <BODY></BODY> tags and enable the Scripting Object Model when asked.


  6. Set the connection of your recordset DTC to be your valid connection and set the Database object to Table and choose a valid Object Name.


  7. Drag a grid DTC onto your page below the recordset and bind it to your recordset. Also, choose a few fields to show in the grid.


  8. Drag a text box DTC onto your page below the grid and bind it to a key or identity field from your recordset DTC.


  9. In the <HEAD></HEAD> tags of your page insert a server script block and paste the following code into the script block:
    
          Sub thisPage_Onshow()
             absPos = Request.QueryString("number")
             If absPos <> "" then
             'absPos = cint(Request.QueryString("number"))
             Recordset1.moveAbsolute(absPos)
             end if
          End Sub 
    NOTE: This code assumes that your recordset DTC is named Recordset1.


  10. Save your page and view it in the browser, make sure you append the following query string value to the URL: ?number=4. NOTE: This assumes that you have four or more records in the table you queried.


  11. You will notice that the text box will have a value corresponding to record 1, meaning that the moveAbsolute did not work.


  12. Uncomment the commented line of code in the thisPage_Onshow() sub, save your page, and view it again with the query string value of 4.


This time you will see that the text box contains data from the fourth record of the recordset.

Additional query words:


Keywords          : kbCtrl kbide kbVisID600 kbGrpASP 
Version           : WINDOWS:6.0
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: May 27, 1999