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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Session Variable to Table

Status
Not open for further replies.

dashusa

Programmer
Mar 27, 2006
46
US
Hello i collecting data from a user for two diffent tables in a data base and i need a unique ID so i can match the data lata...
But when i try to add the Session Variable to the table it adds it over and over ...
Any ideas on how to fix this thanks


<%@ language="JScript" %>
<!-- #include file="adojavas.inc" -->
<html>
<head>
<title>Nutritional answers</title>
</head>
<body>
<%
var connect = Server.CreateObject("ADODB.Connection");
var recordSet = Server.CreateObject("ADODB.RecordSet");
connect.Open("DSN=excuse");
recordSet.Open("select * from Details",connect, adOpenKeyset,adLockOptimistic);

var FN = Request.Form("fn")
var LN = Request.Form("ln")
var A1 = Request.Form("A1")
var A2 = Request.Form("A2")
var CIT = Request.Form("cit")
var STA = Request.Form("sta")
var ZIP = Request.Form("zip")
var PN = Request.Form("pn")
var EM = Request.Form("em")
Session("USER") = Request.Form("user").Item;
var PASS = Request.Form("pass")

recordSet.AddNew();

recordSet("FirstName") = FN
recordSet("LastName") = LN
recordSet("Address1") = A1
recordSet("Address2") = A2
recordSet("City") = CIT
recordSet("State") = STA
recordSet("Zip") = ZIP
recordSet("PhoneNumber") = PN
recordSet("Email") = EM
recordSet("USER") = Session("USER")
recordSet("PASS") = PASS
recordSet.Update();

connect.Close();
connect = null;
Response.Redirect("succesfull.asp")
%>

</body>

</html>
 
sory wrong code this is the propper code
<%@ language="JScript" %>
<!-- #include file="adojavas.inc" -->
<html>
<head>
<title>Nutritional answers</title>
</head>
<body>
<%

var connect = Server.CreateObject("ADODB.Connection");
var recordSet = Server.CreateObject("ADODB.RecordSet");
connect.Open("DSN=excuse");
recordSet.Open("select * from Nutrition",connect, adOpenKeyset,adLockOptimistic);

var User = Session("USER")
var fl = Request.Form("fl")
var BF = Request.Form("BF")
var GS = Request.Form("GS")
var EP = Request.Form("EP")
var AE = Request.Form("AE")
var WT = Request.Form("WT")
var SP = Request.Form("SP")
var TB = Request.Form("TB")

recordSet.AddNew();

recordSet("User") = Session("USER")
recordSet("FoodLabels") = fl
recordSet("GroceryShopping") = GS
recordSet("BreakFast") = BF
recordSet("Excercise") = EP
recordSet("Aerobic") = AE
recordSet("Weights") = WT
recordSet("Sporty") = SP
recordSet("TriedBefore") = TB
recordSet.Update();

connect.Close();
connect = null;
Response.Redirect("#")
%>


%>







</body>
</html>
 
when i try to add the Session Variable to the table it adds it over and over

Do you mean it adds multiple records, or it adds one record but "User" field has the name multiple times (e.g. "TomTomTomTom")?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top