Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capturing and Storing ASP Variables

Status
Not open for further replies.

Harlequin007

Technical User
Feb 9, 2004
249
GB
Hi all.

I've developed an ASP page that captures and Uses some ASP variables such as referrer, browser etc.

How can I then store these variables in a database for example...?

----------------------------
Cogito Ergo Sum [jester2]
----------------------------
 
myVar = request("http_referrer")

set cn = server.createObject("adodb.connection")
cn.open application("connectString")
cn.execute("INSERT myTable (referrer) VALUES ('" & myVar & "'")
cn.close
set cn = nothing

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
MWO - thanks for the quick response.

I'm not entirely sure how I can use that code though - I'm no ASP expert by any stretch of the immagination.

This is what I am capturing:

<%Response.Write(Request.ServerVariables("HTTP_REFERER"))%>

any ideas how I can make use of that sort of ifo - write it directly to a database (which I have yet to develop of-course.

----------------------------
Cogito Ergo Sum [jester2]
----------------------------
 
Let's say you have an access database called "myDB" with a table named "referrers" and the only column in that table is "refName". The database resides in the same directory as the asp page.

Your code would look like this

Code:
<%
myVar = Request.ServerVariables("HTTP_REFERER")

set cn = server.createObject("adodb.connection")
cn.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath("myDB.mdb")
cn.execute("INSERT INTO referrers(refName) VALUES ('" & myVar & "'")
cn.close
set cn = nothing 
%>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
thanks again MWO.

I'll have a play with that tonight. Right now it's a mess, I haven't efev decalred any variables but I'll have to sort that out at some point.

----------------------------
Cogito Ergo Sum [jester2]
----------------------------
 
I'm playing with this at work now. Dropped everything in the root, created the database and get the following error when I browse the page:

cn.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath("myDB.mdb")

----------------------------
Cogito Ergo Sum [jester2]
----------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top