Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Alternate method to writing filter for recordset using session variable

New Here ,
Jul 06, 2009 Jul 06, 2009

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.

TOPICS
Server side applications
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 06, 2009 Jul 06, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 07, 2009 Jul 07, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 07, 2009 Jul 07, 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 08, 2009 Jul 08, 2009

Sorry for the confusion. I am trying to get the 'Welcome' part to display the user's name which is selected from the database per the session variable. On another form, the user enters their userid which is passed to my Welcome page. I have captured the user's userid in a session variable (session("userid_my").  When I insert  request.userid_my code it returns the session variable so I know the session variable is captured however when I insert the recordset associated with 'name' I get an Adobe End of file error. ?

Subsequently, the rest of my recordsets do not function. If I can get the Welcome piece to function correctly, I believe the rest of my recordsets will disperse data.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 08, 2009 Jul 08, 2009

In addition, for the name recordset, my sql statement is as follows:

select name from table_name where userid = '" & namemy & "'"

The statement consistently returns a 'quoted string not properly terminated' error.....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 08, 2009 Jul 08, 2009
LATEST

>When I insert  request.userid_my code it returns the session variable

AFAIK, session variables are not part of the request object - so I do not understand why you are referencing them this way. I would use the standard reference method : Welcome <%Response.Write(Session("username"))%>

>when I insert the recordset associated with 'name' I get an Adobe End of file error. ?

Sounds like a possible problem with your installation. You may need to try reinstalling DW. How are you "inserting" this recordset and when does the error occur?

Regarding your next post...

>select name from table_name where userid = '" & namemy & "'"

>The statement consistently returns a 'quoted string not properly terminated' error.....

The select statement you quoted is obviously not complete. If you are refering to the select in your OP:

Recordset1_cmd.CommandText = "SELECT name FROM table WHERE userid =  '" & Session("userid_my") & "'"

I see nothing wrong with that syntax and the string appears to be terminated correctly. If there is a different statement causing the error, please post the entire line and include a line above and below.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines