Forums
This topic is locked
Record set help
Posted 30 Sep 2005 08:10:26
1
has voted
30 Sep 2005 08:10:26 Evan White posted:
ok so i'm working on the restricted access part 1 tutorial and i was on the part were you're your showing the visitor's names on each page. I add to the recordset sql statement what the tutorial had and it kept giving me an error saying that there is a missing operator. CAn somebody please helpme the code is below.SELECT AccountID, UserAccessLevel, UserAddress1, UserAddress2, UserCityTown, UserCountry, UserDOB, UserEmail, UserFaxno, UserPostcode, UserRegion, UserSurname, UserForename, UserTelephone
FROM website_users
WHERE AccountID = varUserID
SET VarUserID as Session("MM_UserID"
Replies
Replied 30 Sep 2005 12:53:24
30 Sep 2005 12:53:24 Seb Adlington replied:
think it's just a typo, Uppercase Lowercase
WHERE AccountID = varUserID
SET VarUserID as Session("MM_UserID"
VarUserID and .... <b>v</b>arUserID
WHERE AccountID = varUserID
SET VarUserID as Session("MM_UserID"
VarUserID and .... <b>v</b>arUserID
Replied 30 Sep 2005 19:58:37
30 Sep 2005 19:58:37 Evan White replied:
that wasn't the problem but thanks any way i still don't know the problem i went through w3schools trying to learn sql since this problem came up but can't seem to find the problem. I orginally had it more complex and started to get that error then made it simpler and still i'm getting the same thing.
Replied 01 Oct 2005 00:22:14
01 Oct 2005 00:22:14 Seb Adlington replied:
Couple of maybe's for you - if the ID's are text rather than numeric then you need to use WHERE AccountID = 'varUserID'
otherwise here's some working code for you in Javascript to have a nosey at. (based on a text field)
<%
var Recordset1__MMColParam = "1";
if (String(Session("MM_Username") != "undefined" &&
String(Session("MM_Username") != "" {
var1 = String(Session("MM_Username");
}
%>
<%
var Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_pb_STRING;
Recordset1.Source = "SELECT * FROM Users WHERE Username = '"+ var1 + "'";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;
%>
otherwise here's some working code for you in Javascript to have a nosey at. (based on a text field)
<%
var Recordset1__MMColParam = "1";
if (String(Session("MM_Username") != "undefined" &&
String(Session("MM_Username") != "" {
var1 = String(Session("MM_Username");
}
%>
<%
var Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_pb_STRING;
Recordset1.Source = "SELECT * FROM Users WHERE Username = '"+ var1 + "'";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;
%>
Replied 04 Oct 2005 01:06:43
04 Oct 2005 01:06:43 Lee Diggins replied:
Hi Evan
What language are you using?
Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>
What language are you using?
Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>
Replied 04 Oct 2005 02:02:56
04 Oct 2005 02:02:56 Evan White replied:
i'm using asp vbscript
Replied 04 Oct 2005 12:28:58
04 Oct 2005 12:28:58 Lee Diggins replied:
Hi Evan
This is not valid you need to remove it from your SQL code SET VarUserID as Session("MM_UserID". with this code removed you will have a record returned for the varUserID submitted.
I'm not sure what you're going to do with the returned recordset, if all you're going to do is display the visitor name on each page, why have you included all the other data?
An easy way to do this is on the login page, which I'm assuming you have.
1. Edit the login server behaviour SQL SELECT statement to include UserSurname and UserForename along with your username, password and accesslevel fields
2. Edit the login server behaviour to create a session variable and assign it the UserSurname and UserForename values where this line is in the code:
' username and password match - this is a valid user
Session("MM_Username" = MM_valUsername
' Add the following:
Session("myVisitorsName" = MM_rsUser.Fields.Item("UserForename".Value & " " & MM_rsUser.Fields.Item("UserSurname".Value
3. Write the session variable contents to the page
Response.Write(Session("myVisitorsName")
If you get stuck post back.
Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>
This is not valid you need to remove it from your SQL code SET VarUserID as Session("MM_UserID". with this code removed you will have a record returned for the varUserID submitted.
I'm not sure what you're going to do with the returned recordset, if all you're going to do is display the visitor name on each page, why have you included all the other data?
An easy way to do this is on the login page, which I'm assuming you have.
1. Edit the login server behaviour SQL SELECT statement to include UserSurname and UserForename along with your username, password and accesslevel fields
2. Edit the login server behaviour to create a session variable and assign it the UserSurname and UserForename values where this line is in the code:
' username and password match - this is a valid user
Session("MM_Username" = MM_valUsername
' Add the following:
Session("myVisitorsName" = MM_rsUser.Fields.Item("UserForename".Value & " " & MM_rsUser.Fields.Item("UserSurname".Value
3. Write the session variable contents to the page
Response.Write(Session("myVisitorsName")
If you get stuck post back.
Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>