Skip to main content
Participant
July 6, 2009
Question

Alternate method to writing filter for recordset using session variable

  • July 6, 2009
  • 1 reply
  • 1258 views

I'm not sure if this can be done.  I have a user page which I'd like to return database info based upon a userid entered on another page. So far, the session variable (userid) is captured on the user page however it is supposed to return the user's name rather than displaying the session variable.

My problem is this. Within dreamweaver, I am able to create recordsets however I cannot create a filter. The connection works. At this point, I am searching for a workaround where I can tie in the session variable to recordsets. I should make mention that whenever I update the sql statement using the recordset widget, my recordset disappears. ?  At any rate, heres a sample of the code sans connection strings, etc.

----------------------------------------------

<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_newuniversity1_STRING
Recordset1_cmd.CommandText = "SELECT name FROM table WHERE userid =  '" & Session("userid_my") & "'"
Recordset1_cmd.Prepared = true

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>

On the user page, I have a 'Welcome' and the following code

------------------------------------------------------------

{Request.userid_my}

Any suggestions? I'm afraid I'm a newbie to asp within dreamweaver cs3.

This topic has been closed for replies.

1 reply

Participating Frequently
July 6, 2009

I don't quite understand. What exactly is not working correctly in the example code you provided?

WILL0WAuthor
Participant
July 7, 2009

What is not working is the request(userid_my) piece where I'd like for the code to retrieve the 'name' of the user on the page. Instead it displays the userid  of the user. In other words, I'm aiming for a substitution where the name of the user is displayed using a session variable for the user's userid. The underlying sql code is written to extract the name where the userid = session variable (userid_my) or user's userid.

I generated the recordsets using the create recordset in Dreamweaver cs3 however I cannot use Dreamweaver's filter function as I am unable to view the fields of my tables. The connection string works and tests out fine. I have a input form where the user enters data into the table and I am able to view such in the table itself. My problem now is to fine a work around regarding my filtering problem in retrieving data based on the userid session variable.

Participating Frequently
July 7, 2009

Sorry Willow, I'm still not grasping what your problem is.

>In other words, I'm aiming for a substitution where the name of the user is displayed using a session variable for the user's userid.

>The underlying sql code is written to extract the name where the userid = session variable (userid_my) or user's userid.

Your sql looks like it is correctly retrieving the user name. If you want to display that name, then you either need to display that recordset variable directly, or first store it in another session variable and display that. That seems too obvious so I'm guessing I am not understanding fully.  What am I missing here?