Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. 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 Professional 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 January 7th, 2005, 03:36 PM
Registered User
 
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Add new record to databased based on textbox input

I have an on line annual update training that has a certificate that is printed for supervisor signature. I currently have 4 text boxes and one combo box that adds a new record to Access database. I want to change the fill in page to one textbox (SSN) that will get the info from database based on textbox input, add the new record to database and then display the users name on certificate.


 
Old January 10th, 2005, 03:16 AM
Authorized User
 
Join Date: Sep 2004
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to nashnash
Default

can you plz send me the exact requirement more clearly or web page you have .so that it will be easy to fix..

Thanks
Nash

 
Old January 10th, 2005, 01:45 PM
Registered User
 
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The pages work but do not add a new record to the database. I did not create the database so the field names are not user friendly. Thank you for your help:
"textboxsignin.asp"



<html>
<head>

<title>textbox SSN</title>
</head>
<body>
<%



SQL = "SELECT * FROM TRAINING"

Set RecordSet = Server.CreateObject("ADODB.Recordset")

RecordSet.Open SQL, conn, cmdDC


Response.Write("<h2>Please include dashes (123-12-1234)</h2>")


Response.Write("<form method='post' action='textboxview.asp'>")

'displays box for SSN input

Response.Write("<input type='text' name='strSSN' size='46'>")

' Display command button
Response.Write("<br><br>")
Response.Write("<input type='submit' value='Submit SSN'>")
Response.Write("<input type='hidden' name='[CLASS]' value='Online'>")
Response.Write("<input type='hidden' name='DATE' value='NOW()'>")
Response.Write("<input type='hidden' name='Hours' value='1'>")
Response.Write("<input type='hidden' name='HRDIS' value='1234'>")


Response.Write("</form>")

%>
</body></html>



"textboxview.asp"



<head>
<title>Database Example</title>
</head>
<body bgColor="#FFFFFF">
<center>

<%

Set rst = Server.CreateObject("ADODB.Recordset")
SSN = Request("strSSN")


Select Case trim(SSN)
    Case ""
        strSql = "select * From TRAINING WHERE SSN = '" & SSN & "' "
    Case Else
        'strSql = "select * From TRAINING WHERE SSN like '" & SSN & "' & INSERT INTO TRAINING (NAMElast,NAMEfirst,SSN) VALUES('" & request.Form("NAMElast") & "','" & request.Form("NAMElast") & "','" & request.Form("SSN") & "')"
    strSql = "select * From TRAINING WHERE SSN = '" & SSN & "' "
End Select

'requesting info from signin form for database
NAMElast = request.form("NAMElast")
NAMEfirst = request.form("NAMEfirst")
MI = request.form("MI")
SSN = request.form("SSN")
[CLASS] = request.form("CLASS")
'DATE = request.form("DATE")
Hours = request.form("Hours")
HRDIS= replace(HRDIS,"'","''")

'adding info to database
        rst = "INSERT INTO TRAINING (NAMElast,NAMEfirst,MI,SSN,CLASS,DATE,Hours,HRDIS) "
        rst = strSql & " VALUES ("
        rst = strSql & "'" & NAMElast & "'"
        rst = strSql & "'" & NAMEfirst & "'"
        rst = strSql & "'" & MI & "'"
        rst = strSql & "'" & SSN & "'"
        rst = strSql & "'" & [CLASS] & "'"
        rst = strSql & "'" & DATE & "'"
        rst = strSql & "'" & Hours & "'"
        rst = strSql & "'" & HRDIS & "'"
        rst = strSql & ")"


NAMElast = request.form("NAMElast")
NAMEfirst = request.form("NAMEfirst")
SSN = request.form("SSN")
SSN= replace(SSN,"'","''")

rst = conn.execute (strSql)
'rst.Open strProvider, strSql, adOpenStatic

'adding a response
If err.number>0 then
   response.write "VBScript Errors Occured:" & "<P>"
    response.write "Error Number=" & err.number & "<P>"
    response.write "Error Descr.=" & err.description & "<P>"
    response.write "Help Context=" & err.helpcontext & "<P>"
    response.write "Help Path=" & err.helppath & "<P>"
    response.write "Native Error=" & err.nativeerror & "<P>"
    response.write "Source=" & err.source & "<P>"
    response.write "SQLState=" & err.sqlstate & "<P>"
   end if
   IF conn.errors.count> 0 then
    response.write "Database Errors Occured" & "<P>"
    response.write strSql & "<P>"
   for counter= 0 to conn.errors.count
    response.write "Error #" & conn.errors(counter).number & "<P>"
    response.write "Error desc. -> " & conn.errors(counter).description & "<P>"
   next
   else
    response.write "<center><br><br><br><br>"
    response.write ""
    response.write "Thank you"
    response.write "<br>"
    response.write ""
    response.write "Your name has been added to the BBP Database<p></center>"
   end if

%>

<align="center"><%=rst("NAMEfirst") %><%response.write(" ")%><%=rst("NAMElast") %></I> </b></p><br>

  <p align="center"><b>has successfully
    completed the online</b></p>
  <p align="center">Lakeland
  Village</p>
  <p align="center">&nbsp;Annual BBP\TB
  Update </p>
  <p align="center"><b>Date Completed:<%response.write(date())%>

    </b></p>
  <p align="center"><b>Supervisor Signature:
    ________________________________________</b></p>
  <p align="left">&nbsp;
  <input type="button" name="printWhole" value="Print Certificate" onclick="parent.print()">&nbsp;
  <input type="button" value="Finish" name="exitwindow" onclick="window.close();"response.write("Thank You")><p align="center">


    <input type=hidden name="NAMEfirst" value="">

  <strong><span style="text-transform: uppercase">A copy
  of this document must be filed in the employee's personnel file</span></strong></form>
<p>&nbsp;</p>



  </HTML>

  </BODY>







Similar Threads
Thread Thread Starter Forum Replies Last Post
TextBox - formattering input after event modelplane Visual Basic 2005 Basics 0 December 10th, 2006 03:06 PM
Form Input, Parameters, Report Based on Query DavidWE Access VBA 2 November 6th, 2006 10:36 AM
Moving input from textbox to field stealthdevil Access VBA 7 May 24th, 2006 11:33 AM
Validation of TextBox Input bpgadhia ASP.NET 1.0 and 1.1 Professional 1 March 16th, 2004 05:07 PM





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