Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why isnt recordset sort method working?

Status
Not open for further replies.

Albuckj2

Programmer
Jan 7, 2003
68
0
0
GB

I have an ASP page that creates a recordset (based on some user's entry into a form on a previous page) and then writes a HTML table based on that recordset. I need to allow the user to sort the table by clicking the table headings. I want this done on the client side. My plan is the use the sort method of the recordset object and then re-write the HTML table with the correctly sorted table.

However, I can't get the sort method to work I think it has something to do with the cursors or something. Here's the rough structure of my ASP page:

Const adOpenStatic = 3
.
.
.
Dim objConn, strConnection
set objConn = Server.CreateObject("ADODB.Connection")
strConnection = "DSN=Connect1"
objConn.Open strConnection
.
.
.
Dim strQ, sells(40), regs(40), display, displaycount
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Set Recordset1.ActiveConnection = objConn
Recordset1.CursorLocation = adUseClient
Recordset1.CursorType = adOpenDynamic
.
.
.
Recordset1.Open strQ, objConn, 3, 3



It doesn't like the following line: Recordset1.CursorLocation = adUseClient
It says: "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."
Any idea of what is the problem????
 
See my wonderfull LOL Faq on how to reorder table content : faq216-2692. It should help. Water is not bad as long as it stays out human body ;-)
 
mmmm, this doesn't really tell me why my recordset object can't perform it's sort method.

Something to do with cursors???

Anyone know why this is???
 
I know that "this doesn't really tell you why your recordset object can't perform it's sort method" but you said in your first post "I want this done on the client side.". As, in general, recordset are used server-side, I think this is the only method to reorder your data without going back to the server. By the way, if you really want to use recordset.sort, check the openning options of your recordset ("Recordset1.Open strQ, objConn, 3, 3") : the third parameter (in red) corresponds to the cursor type. 3 is "adOpenStatic" value. Try a "adOpenDynamic" (value "2"). It should work better... Water is not bad as long as it stays out human body ;-)
 
Ahhh....
Sorry, I'm not very clever. Didn't realise that using the sort method of the recordset required a trip back to the server. In that case, I'll have to try and implement a solution with the help of your FAQ.

I'll let you know how I get on.

Cheers.
 
Make sure that you are using a client side cursor. You should always use the client side cursor (note: there may be a problem with using client side cursors with auto number fields. I can't remember). Anyway, set the cursor location before openning the connection.

conn.SetLocation = 3 ' Gives client side cursor

--- or ----

conn.SetLocation = 2 ' Gives server side cursor

------------------
I hope this helps.
 
One piece of information for clarification. When we are talking about client vs server cursors, this is not the same client and server as the browser and web server. In terms of database connections your web server is the client and your database is the server.
So setting the cursor to client control does not make a recordset accessible with client-side script.
-Tarwn [sub]01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101 [/sub]
[sup]29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19[/sup]
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top