Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 12th, 2008, 11:30 AM
Authorized User
 
Join Date: Jan 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Logging ASP data to SQL

Can anyone give me some direction on saving ASP login information to a SQL database. I have been trying for days to capture the login information from my site and do an INSERT INTO my SQL server.

Code:
Dim objConn
Dim strSQL1
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Driver={SQL Server};Server=servername\SQLEXPRESS;UID=username;PWD=password;Language=us_english;Database=testdb;DSN=;"

     strSQL1 = "INSERT INTO site_activity ([user_name],[user_password],[ip_address]) VALUES " & _
         "('" & Session("username") & "','" & _
          Session("password") & "','" &_
          Request.ServerVariables("REMOTE_ADDR") & "')"
     objconn.execute strSQL1
the problem is I can not seem to capture the remote_addr? anyone know how to capture that with the request.servervariables("remote_addr")? thanks :)


EDIT: looks like im getting lucky i fixed this one also: I used the following code:

Code:
Dim objConn
Dim strSQL1
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Driver={SQL Server};Server=computername\SQLEXPRESS;UID=username;PWD=password;Language=us_english;Database=testdb;"

     strSQL1 = "INSERT INTO site_activity ([user_name],[user_password],[date],[ip_address]) VALUES " & _
         "('" & Session("username") & "','" & _
          Session("password") & "','" &_
          now & "','" &_
          Request.ServerVariables("REMOTE_HOST") & "')"
     
     objconn.execute strSQL1
good day to all! :D
__________________
keep your kneeze in the breeze
 
Old March 12th, 2008, 06:01 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Glad you got it sorted.

Looking at you code posses a question:
Do you have your connection string in each page where you connect? Think about putting this and other code you use in many areas in a global file which gets included whee neccesary. Believe me when you need to alter your connections string (which you will do) changing one file is very very handy...

Wind is your friend
Matt
www.elitemarquees.com.au
 
Old March 12th, 2008, 09:46 PM
Authorized User
 
Join Date: Jan 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks mat41 good advice, i will do that.
 
Old March 12th, 2008, 09:53 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

No worries.

I place ALL constants; things like is mailEnabled, myMaiIP, DBName, uName, pWord etc...
Also commonly dimmed variables etc...

Also think about having a global functions file for your VBScript and a global javascript function file etc...

makes life alot easier for so many reasons...

Wind is your friend
Matt
www.elitemarquees.com.au





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with ms sql-server abd logging hertendreef ASP.NET 2.0 Basics 12 May 1st, 2006 03:15 PM
SSIS - Built-In Logging / Custom Logging ivobecker23 SQL Server 2005 0 April 21st, 2006 05:41 AM
Insert data in SQL ASP .NET 2.0. alexsaiz82 ASP.NET 2.0 Basics 0 January 3rd, 2006 03:28 PM
Logging in to SQL Server mark.roworth Access VBA 4 August 30th, 2004 01:39 PM
ASP database to personalise logging in ammy Classic ASP Databases 0 March 29th, 2004 07:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.