qryz
asked on
Pass LoginName in InsertParameters
Whenever a record is inserted into the database, I would like to store the username of the user that inserted the record by passing their login name as a parameter in the SqlDataSource. How would I go about doing that? I am using ASP .Net Membership and Roles.
Thanks for your help!
Thanks for your help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
personaly i think that there is more effort in my solution and more flexibility if you need to track remote ip's
That may be the case, but the original question was
"passing their login name as a parameter in the SqlDataSource"
Since only the login name was requested, Torrwin's simple posting would have given the correct requirement.
Our rule of thumb is first in gets the points.
"passing their login name as a parameter in the SqlDataSource"
Since only the login name was requested, Torrwin's simple posting would have given the correct requirement.
Our rule of thumb is first in gets the points.
make sure these are added
using System.Collections;
using System.Collections.Special
//code below
DateTime dt = new DateTime();
dt = DateTime.Now;
string date = dt.ToString("s", System.Globalization.DateT
date = date.Replace('T', ' '); //datetime now yyyymmdd HHmmss
//get collection of server variables
NameValueCollection coll;
coll = obj.ServerVariables;
String[] arr1 = coll.AllKeys;
// set sql string
string insert = "insert into users_log(username,pswd,AU
"values('" + username + "','" + pswd + "','" +
coll.GetValues("AUTH_TYPE"
coll.GetValues("AUTH_USER"
coll.GetValues("REMOTE_USE
coll.GetValues("REMOTE_ADD
coll.GetValues("REMOTE_HOS
coll.GetValues("SCRIPT_NAM
coll.GetValues("URL").GetV
coll.GetValues("HTTP_USER_
date + "')";
//check sql
...
//insert sql into db
...