Forums

This topic is locked

Login & Search page recordset.

Posted 23 Dec 2005 08:27:20
1
has voted
23 Dec 2005 08:27:20 Malcolm X posted:
Can anyone suggest the best way to have a message in a search page saying
"Welcom Bob, thank you for visiting our site".

I have a login.asp page which has the Login Server Behaviour, search.asp page which has the ;log out server behaviour, and an access database called dbase.mdb with a field called "users" and column called "christainName" Using Dreamweaver and ASP.

Replies

Replied 28 Dec 2005 06:31:47
28 Dec 2005 06:31:47 Jeremy Conn replied:
Conceptually, you simply need to pull the name from the DB by displaying the users info filtered by the authenticated login ID. See below...

<b>PLACE THIS RECORDSET INTO YOUR PAGE</b>
<font color=red>Change items in RED to reflect your data</font id=red>

' *** This code sets the filter parameter to the validated username
&lt;%
Dim rsUserInfo__MMColParam
rsUserInfo__MMColParam = "1"
if (Session("MM_Username" &lt;&gt; "" then rsUserInfo__MMColParam = Session("MM_Username"
%&gt;

' *** This code pulls back the user's name from your DB using the filter parameter above
&lt;%
set rsUserInfo = Server.CreateObject("ADODB.Recordset"
rsUserInfo.ActiveConnection = <font color=red>MM_DBConnection_STRING</font id=red>
rsUserInfo.Source = "SELECT * FROM <font color=red>TableName</font id=red> WHERE <font color=red>UserName</font id=red> = '" + Replace(rsUserInfo__MMColParam, "'", "''" + "'"
rsUserInfo.CursorType = 0
rsUserInfo.CursorLocation = 2
rsUserInfo.LockType = 3
rsUserInfo.Open()
rsUserInfo_numRows = 0
%&gt;


<b>PLACE THIS INTO YOUR PAGE TO CALL THE NAME</b>

&lt;%=(rsUserInfo.Fields.Item("ChristainName".Value)%&gt;

<b>Jeremy Conn</b>
www.conncreativemedia.com
DWMX2004 | ASP/VB | Access/SQL2000

Edited by - connman21 on 28 Dec 2005 06:33:14
Replied 28 Dec 2005 09:24:42
28 Dec 2005 09:24:42 Malcolm X replied:
Jeremy, thanks so much for answering my question. I have been plating with this for weeks now.

I did do as mentioned.
a) copy all data in 1st section to the login page.
b) changed the connection string to read MM_connTimber_STRING
c) TableName to tblUsr. This is exactly how it reads in my database.
d) UserName i tried both UsrName & ChristianName. These are both in my Access database.
e) then copied &lt;%=(rsUserInfo.Fields.Item("ChristainName".Value)%&gt; in to the logged in page.

I received the following error.
Microsoft VBScript runtime error '800a01a8'
Object required: ''
/html/loggedin.asp, line 252

This line reads;
252 &lt;%=(rsUserInfo.Fields.Item("ChristainName".Value)%&gt;

I have been having the same problem all week.

Any suggestions?
Replied 28 Dec 2005 20:30:08
28 Dec 2005 20:30:08 Jeremy Conn replied:
The recordset needs to go onto your 'logged in' page, not your 'login' page.
Also, looks like "ChristianName" was misspelled - try that and see how it goes.

<b>Jeremy Conn</b>
www.conncreativemedia.com
DWMX2004 | ASP/VB | Access/SQL2000

Edited by - connman21 on 28 Dec 2005 20:31:31

Edited by - connman21 on 28 Dec 2005 22:16:50
Replied 28 Dec 2005 22:50:04
28 Dec 2005 22:50:04 Malcolm X replied:
Hey, thanks for that, got a better result.

Comes up with the following:

ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/html/loggedin.asp, line 290

In the login page we have added the following.

&lt;%
Dim rsUserInfo__MMColParam
rsUserInfo__MMColParam = "1"
if (Session("MM_Username" &lt;&gt; "" then rsUserInfo__MMColParam = Session("MM_Username"
%&gt;
&lt;%
set rsUserInfo = Server.CreateObject("ADODB.Recordset"
rsUserInfo.ActiveConnection = MM_connTimber_STRING
rsUserInfo.Source = "SELECT * FROM tblUsr WHERE ChristianName = '" + Replace(rsUserInfo__MMColParam, "'", "''" + "'"
rsUserInfo.CursorType = 0
rsUserInfo.CursorLocation = 2
rsUserInfo.LockType = 3
rsUserInfo.Open()
rsUserInfo_numRows = 0
%&gt;

In the logged in page we have added the following.
&lt;%
Dim rsUserInfo__MMColParam
rsUserInfo__MMColParam = "1"
if (Session("MM_Username" &lt;&gt; "" then rsUserInfo__MMColParam = Session("MM_Username"
%&gt;
&lt;%
set rsUserInfo = Server.CreateObject("ADODB.Recordset"
rsUserInfo.ActiveConnection = MM_connTimber_STRING
rsUserInfo.Source = "SELECT * FROM tblUsr WHERE ChristianName = '" + Replace(rsUserInfo__MMColParam, "'", "''" + "'"
rsUserInfo.CursorType = 0
rsUserInfo.CursorLocation = 2
rsUserInfo.LockType = 3
rsUserInfo.Open()
rsUserInfo_numRows = 0
%&gt;

&lt;%=(rsUserInfo.Fields.Item("ChristianName".Value)%&gt;

I have had this error quite a few times before, i think this migh be the main problem i have had.

Can you suggest?

Thanks in advance.

Malcolm
Replied 29 Dec 2005 16:48:09
29 Dec 2005 16:48:09 Dave Clarke replied:
That means the recordset you are trying to display has no records, probably because nobody is logged in, you need to only show your welcome message if someone is logged in.

<b>&lt;% If Not rsUserInfo.EOF Or Not rsetUserInfo.BOF Then %&gt;</b>
&lt;%=(rsUserInfo.Fields.Item("ChristianName".Value)%&gt;
<b>&lt;% End If %&gt;</b>

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome.
Replied 29 Dec 2005 23:47:24
29 Dec 2005 23:47:24 Malcolm X replied:
Thanks Dave & Jeremy. I think I am running out of things to try here.

I inserted the code in to my logged in page and got the following.

Microsoft VBScript runtime error '800a01a8'
Object required: ''
/html/search.asp, line 354

354 &lt;% If Not rsUserInfo.EOF Or Not rsetUserInfo.BOF Then %&gt;
355 &lt;%=(rsUserInfo.Fields.Item("ChristianName".Value)%&gt;
356 &lt;% End If %&gt;
Replied 31 Dec 2005 02:20:54
31 Dec 2005 02:20:54 Jeremy Conn replied:
Couple things I can see:

1) You don't need the additional recordset I gave you on your login page, only on the page that you want to display the name on.
2) Do you have a user record in your <b>tblUsr</b> table?

<b>Jeremy Conn</b>
www.conncreativemedia.com
DWMX2004 | ASP/VB | Access/SQL2000
Replied 31 Dec 2005 03:16:52
31 Dec 2005 03:16:52 Malcolm X replied:
Ok I see, so far we have a the recordset listed above in the logged in page, this &lt;%=(rsUserInfo.Fields.Item("ChristainName".Value)%&gt; also in the logged in page.

Also I have a table called tblUsr and in that table I have idUsr, usrName, christianName, familyName & passWord columns.

This look good so far?

Actually should I have any recordset in the login page or is this recordset pulling from the "Login User Server Behaviour"?

Thanks for your persistence.

Replied 31 Dec 2005 21:30:04
31 Dec 2005 21:30:04 Jeremy Conn replied:
OK, I think I see how this needs to be...
replace the entire code piece I gave you on the 'logged in' page with this... changed piece is highlighted in orange.


&lt;%
Dim rsUserInfo__MMColParam
rsUserInfo__MMColParam = "1"
if (Session("MM_Username" &lt;&gt; "" then rsUserInfo__MMColParam = Session("MM_Username"
%&gt;
&lt;%
set rsUserInfo = Server.CreateObject("ADODB.Recordset"
rsUserInfo.ActiveConnection = MM_connTimber_STRING
rsUserInfo.Source = "SELECT * FROM tblUsr WHERE <b><font color=orange>usrName</font id=orange></b> = '" + Replace(rsUserInfo__MMColParam, "'", "''" + "'"
rsUserInfo.CursorType = 0
rsUserInfo.CursorLocation = 2
rsUserInfo.LockType = 3
rsUserInfo.Open()
rsUserInfo_numRows = 0
%&gt;


That should do the trick... JC

<b>Jeremy Conn</b>
www.conncreativemedia.com
DWMX2004 | ASP/VB | Access/SQL2000

Edited by - connman21 on 31 Dec 2005 21:30:44
Replied 31 Dec 2005 23:47:23
31 Dec 2005 23:47:23 Malcolm X replied:
Ok thanks for that. Just want to make sure I have this right,.

In the login page I do nothing as it already has the "Login User Server Behaviour".
In the logged in page I insert the following.

a)

&lt;%
Dim rsUserInfo__MMColParam
rsUserInfo__MMColParam = "1"
if (Session("MM_Username" &lt;&gt; "" then rsUserInfo__MMColParam = Session("MM_Username"
%&gt;

b)
&lt;%
set rsUserInfo = Server.CreateObject("ADODB.Recordset"
rsUserInfo.ActiveConnection = MM_connTimber_STRING
rsUserInfo.Source = "SELECT * FROM tblUsr WHERE usrName = '" + Replace(rsUserInfo__MMColParam, "'", "''" + "'"
rsUserInfo.CursorType = 0
rsUserInfo.CursorLocation = 2
rsUserInfo.LockType = 3
rsUserInfo.Open()
rsUserInfo_numRows = 0
%&gt;

c)
&lt;%=(rsUserInfo.Fields.Item("ChristainName".Value)%&gt;

To confirm, I hve a table called tblUsr and in there columns called idUsr, usrName, christianName, familyName & passWord.

The name which we want to appear when logged in is the christianName.

Thanks
Mally
Replied 01 Jan 2006 02:49:34
01 Jan 2006 02:49:34 Malcolm X replied:
Hey there, sorry if the above is correct, we get the following.

ADODB.Fields error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal.

/html/search.asp, line 290

Line 290 reads, &lt;%=(rsUserInfo.Fields.Item("ChristainName".Value)%&gt;

Mally.
Replied 01 Jan 2006 07:37:30
01 Jan 2006 07:37:30 Jeremy Conn replied:
You spelled 'Christian' wrong... should be:

&lt;%=(rsUserInfo.Fields.Item("<b>Christian</b>Name".Value)%&gt;

<b>Jeremy Conn</b>
www.conncreativemedia.com
DWMX2004 | ASP/VB | Access/SQL2000
Replied 02 Jan 2006 23:06:40
02 Jan 2006 23:06:40 Malcolm X replied:
it worked perfectly.

Thank you both.

Mally.


Replied 04 Jan 2006 23:47:54
04 Jan 2006 23:47:54 Jeremy Conn replied:
Sweet - Glad you got it working.

<b>Jeremy Conn</b>
www.conncreativemedia.com
DWMX2004 | ASP/VB | Access/SQL2000
Replied 05 Jan 2006 19:28:23
05 Jan 2006 19:28:23 Dave Clarke replied:
Excellent, glad you got it working. <img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome.
Replied 17 May 2006 07:43:21
17 May 2006 07:43:21 robert ham replied:
how you doin jeremy ?!
i'm just wodering, umm what do u mean by MM_DBConnection_STRING ?
its like conn open "..." "..." "..." ??

Reply to this topic