PRB: Recordset DTC moveAbsolute Does Not Work With QueryString
ID: Q194024
|
The information in this article applies to:
-
Microsoft Visual InterDev, version 6.0
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
- Create a new project in Visual InterDev 6.0.
- Make sure that the default script language is set to Server: VBScript
and Client: JavaScript.
- Create a valid data connection for your project.
- Add a new Active Server Page (ASP) to the project.
- Drag a recordset DTC onto the ASP page between the <BODY></BODY> tags
and enable the Scripting Object Model when asked.
- 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.
- 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.
- Drag a text box DTC onto your page below the grid and bind it to a key
or identity field from your recordset DTC.
- 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.
- 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.
- You will notice that the text box will have a value corresponding to
record 1, meaning that the moveAbsolute did not work.
- 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