Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 12th, 2008, 11:30 AM
Authorized User
 
Join Date: Jan 2008
Location: kokomo, IN, USA.
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
Reply With Quote
  #2 (permalink)  
Old March 12th, 2008, 06:01 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
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
Reply With Quote
  #3 (permalink)  
Old March 12th, 2008, 09:46 PM
Authorized User
 
Join Date: Jan 2008
Location: kokomo, IN, USA.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks mat41 good advice, i will do that.
Reply With Quote
  #4 (permalink)  
Old March 12th, 2008, 09:53 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 02: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 06:23 AM



All times are GMT -4. The time now is 02:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.