Read, Edit, Update Record

Results 1 to 2 of 2

Thread: Read, Edit, Update Record

  1. #1
    Join Date
    Dec 1969

    Default Read, Edit, Update Record

    I have five files, three pages. Using Access 2002, ASP: <BR><BR>1.asp is the form that the user fills out, goes to 2.asp to add the data to the table, to 3.asp to read the record and display the results. User clicks on Edit to go to 4.asp to display an edit form, makes corrections. User clicks submit which goes to 5.asp which should: <BR><BR>A)read the record, B)pick up the corrected input, C)update the record. <BR><BR>What I can’t get is this file (5.asp) to read the record (it just has blanks in the fields) and update that record with any changes made on the form. Please help! <BR><BR>&#060;% <BR>Dim strDBPathCust <BR>Dim cnnStrCustDB <BR>Dim rstStrCustDB <BR>Dim strSqlCust <BR>Dim OrdNum <BR><BR>&#039;Retrieve session variable <BR>OrdNum = session("OrderNumberVar") <BR><BR>&#039; set path to table <BR>strDBPathCust = Server.MapPath("../StrDB/StrCust.mdb") <BR><BR>&#039; create connection <BR>Set cnnStrCustDB = Server.CreateObject("ADODB.Connection") <BR><BR>&#039; open connection to table <BR>cnnStrCustDB.Open "DBQ=" & strDBPathCust & ";" & "DRIVER={Microsoft Access Driver (*.mdb)};" <BR><BR>&#039; create recordset object <BR>Set rstStrCustDB = Server.CreateObject("ADODB.Recordset") <BR><BR>&#039; open the recordset <BR>rstStrCustDB.Open "SELECT * from StoCust", cnnStrCustDB, adOpenKeyset, adLockOptimistic <BR><BR>&#039; fields to update database from form <BR>rstStrCustDB.Fields("FName") = Request.Form("FName") <BR>rstStrCustDB.Fields("LName") = Request.Form("LName") <BR>rstStrCustDB.Fields("HomePhone") = Request.Form("HomePhone") <BR><BR>&#039; update the record <BR>rstStrCustDB.Update <BR><BR>&#039; close recordset <BR>rstStrCustDB.Close <BR><BR>&#039; close connection <BR>cnnStrCustDB.Close <BR><BR>&#039; clear objects <BR>Set rstStrCustDB = Nothing <BR>Set cnnStrCustDB = Nothing <BR>%&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: Read, Edit, Update Record

    Hmm, I&#039;d like to suggest a slightly different approach:<BR><BR>1.asp lets the user fill out a form<BR><BR>submit takes them to 2.asp which displays the inputted values, then the user has two options: edit & save. Edit takes them to edit.asp, save takes them to save.asp. After people edited their records, submit takes then again to 2.asp.<BR><BR>This way you only make one connection to the database. You could use Session Variables to store the results, or hidden form elements.<BR><BR>Don&#039;t you agree this is a better way?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts