Print Page | Close Window

Interacting with Cookies. SQL Problems

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Web Design Discussion
Forum Description: Discussion on web design and development subjects.
URL: https://forums.webwiz.net/forum_posts.asp?TID=11507
Printed Date: 29 March 2026 at 2:57pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Interacting with Cookies. SQL Problems
Posted By: niugiovanni
Subject: Interacting with Cookies. SQL Problems
Date Posted: 11 August 2004 at 1:10am

Hey guys,

I'm just getting into ASP and have finished installing WebWiz SQL.  I have everything running correctly, including having the forums generate content on the webpage.  One thing I'd like to do is make it so when a user visits the homepage it checks for their webwiz cookie and, if they've logged in, shows if they have new PM's, or if a certain forum category has updated etc...

After searching the forums I figured out how to use the user_code and match it with the WWF cookie the user holds.  For some reason though when I execute the following code:

Quote

strUserCode = Request.Cookies("WWF")("UID")
Response.Write("UserCode: " & strUserCode)
 
'open database
set connCookieTemp = Server.CreateObject("ADODB.Connection")
cookieSQL = "Provider=SQLOLEDB;Server=" & strSQLServerName & ";User ID=" & strSQLDBUserName & ";Password=" & strSQLDBPassword & ";Database=" & strSQLDBName & ";"
connCookieTemp.Open cookieSQL
set rscookietemp = Server.CreateObject("ADODB.Recordset")
'If a cookie exsists on the users system then read in there username from the database
If strUserCode <> "" Then
Response.Write("Cookies!  Yes!")
cookieSQL = "SELECT * FROM tblAuthor WHERE User_Code = "&strUserCode
set rscookietemp=connCookieTemp.execute(cookieSQL)
strShownUsername = rscookietemp("Username")
Response.Write("Found Ya!" & strShownUsername)
Else
Response.Write("No Cookies? Please Log-In")
End If

I get an error telling me "invalid column name" and then the cookie's info.  Anyone know why I'm getting a column error when it should be trying to match the user_code?

Thank you all in advance.




Replies:
Posted By: dj air
Date Posted: 14 August 2004 at 8:27am
for the cookieSQL you are better off using

cookieSQL = "SELECT * FROM tblAuthor WHERE tblAuthor.User_Code = '"&strUserCode &"'

if you put them into quotes anything in them are one value .. and prevents errors.

not sure if that will solve your problem ..

ussually invalid collumn name can be  where you have wrong sever verables for example using True and False on an SQL server query where it should be 0 and 1.


Posted By: Gullanian
Date Posted: 14 August 2004 at 8:03pm
Non numeric comparisons should always be enclosed in single quotes as dj air said.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net