Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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
  #1 (permalink)  
Old March 1st, 2004, 11:40 AM
Authorized User
Join Date: Feb 2004
Location: , , .
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help..how to make confirmation code

Hi....I need help pleesseeaaa....Thank in advance for your help.
I have been working with my code and i just cant figure out how to make my confirmation form works.
With confirmation page.
It will also will do some checking first if the user add the same
EmployeeID it will show 'data already exists' and it will return to form 1.asp if the data never been add before it will do
another checking everytime User want to save it will show that 'Data have been saved', If the user change their mind
not to save the data it will show 'Data have been cancel '.

this my code:

<FORM ACTION="ResultADD.asp" METHOD=post Name=frmAdd>

<TABLE style="WIDTH: 402px; HEIGHT: 172px" cellSpacing=1 cellPadding=1 width=402

    <TD><INPUT type="text" name="EmpID" value="<%=session("ID")%>" ></TD></TR>
    <TD><INPUT type="text" name="EmpName" value="<%=session("SName")%>" ></TD></TR>
    <TD><INPUT type="text" name="EmpAddress" value="<%=session("Address")%>" ></TD></TR>
    <TD><INPUT type="text" name="EmpPhone" value="<%=Session("PhoneHome")%>" ></TD></TR>
    <TD><SELECT type="dropdown" name="EmpPostal" value="<%=Session("PostalCode")%>" style="WIDTH: 154px" > <OPTION selected>
    <TD><INPUT type="text" name="EmpSalary" value="<%=Session("Salary")%>" ></TD></TR>

<P><INPUT type=submit value=Submit name=submit1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT id=reset1 type=reset value=Reset name=reset1></P><BODY>

Dim strConnect, strsql, strTo

Session("ID") = Request.Form("EmpID")
Session("SName") = Request.Form("EmpName")
Session("Address") = Request.Form("EmpAddress")
Session("PhoneHome") = Request.Form("EmpPhone")
Session("PostalCode") = Request.Form("EmpPostal")
Session("Salary") = Request.Form("EmpSalary")

strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data

Set Conn= Server.CreateObject ("ADODB.Connection")
Conn.Open strConnect

strsql = "INSERT INTO Data(EmployeeID,EmployeeName,EmployeeAddress, EmployeePhoneHome, EmployeePostalCode, EmployeeSalary) " & _
         "VALUES('"& session("ID")&"','"& session("SName")&"','"& session("Address")&"', " & _
         "'"& session("PhoneHome")&"','"& session("PostalCode")&"','"& session("Salary")&"')"
Conn.Execute strSQL
set Conn = nothing

Session("EmployeeID") = ""
Session("EmployeeName") = ""
Session("EmployeeAddress") = ""
Session("EmployeePhoneHome") = ""
Session("EmployeePostalCode") = ""
Session("EmployeeSalary") = ""

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<FORM ACTION=ConfirmADD.asp METHOD=post Name=frmConfirm>
Response.Write "<br>" & Session("ID") & "</br>"
Response.Write "<br>" & Session("SName") & "</br>"
Response.Write "<br>" & Session("Address") & "</br>"
Response.Write "<br>" & Session("PhoneHome") & "</br>"
Response.Write "<br>" & Session("PostalCode") & "</br>"
Response.Write "<br>" & Session("Salary") & "</br>"

<P>&nbsp;<INPUT id=submit1 style="WIDTH: 63px; HEIGHT: 35px" type=submit size=21 value=Save name=submit1>
<INPUT style="WIDTH: 63px; HEIGHT: 35px" type=submit size=21 value=Cancel ></P>

Dim strTo
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

<% If strTo <> "'Exists'" then %>
     <% Response.Write "<CENTER>Data alredy exists</CENTER>"
         Response.Redirect ("Form1.asp") %>
     <% else %>
     <% Response.Write "<CENTER>data was saved to the database</CENTER>"%>
    <% end if %><CENTER> </CENTER>

was saved to the database.

<INPUT id=submit1 style="WIDTH: 127px; HEIGHT: 46px" type=button size=42 value=Back

any help and suggestion really appreciate
  #2 (permalink)  
Old March 3rd, 2004, 02:09 PM
Friend of Wrox
Join Date: Sep 2003
Location: Minneapolis, MN, USA.
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post

I would recommend NOT using session variables unless you plan on using those variables and their respective values repeatedly in your app, which you are not as you are reseting them in Form3.asp. Just try requesting those values and setting plain old variables. If you need to show those values on the confirmation page, which it doesn't look like you do, then just query those out for that specific ID.

EmployeeId = request("EmployeeId")
EmployeeName = request("EmployeeName")

and so on.

If it were me, I would also go with an update query rather than an insert. Even though it may be a millisecond slower, it will give you more flexability in your select statement to either add a new record or update an existing record.

'--start page2 code--
cn = "Your connection string"

EmployeeId = request("EmployeeId")
EmployeeName = request("EmployeeName")
EmployeeAddress = request("EmployeeAddress")
EmployeePhoneHome = request("EmployeePhoneHome")
EmployeePostalCode = request("EmployeePostalCode")
EmployeeSalary = request("EmployeeSalary")

set rs = server.createobject("adodb.recordset")
sql = "select * from Data where EmployeeId = " & EmployeeId
rs.open sql, cn, 3, 3
if rs.eof then
    rs("EmployeeId") = EmployeeId
end if
    rs("EmployeeName") = EmployeeName
    rs("EmployeeAddress") = EmployeeAddress
    rs("EmployeePhoneHome") = EmployeePhoneHome '--this like ET or something?--
    rs("EmployeePostalCode") = EmployeePostalCode
    rs("EmployeeSalary") = EmployeeSalary
'--end page2 code--

That's just my opinion though.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Make IDE independent code getusama Java Basics 0 December 2nd, 2006 02:20 PM
code to make a list, anyone see what is wrong? am6019a VB How-To 3 July 13th, 2006 10:30 AM
make javascript code more dynamic crmpicco Javascript How-To 3 October 17th, 2005 05:40 AM
make javascript code more dynamic crmpicco Javascript How-To 1 September 27th, 2005 11:44 AM
Ideas to make code better fs22 Javascript 0 June 23rd, 2004 11:16 AM

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