Form Data not carrying over???

Discussion in 'ASP General' started by Matt, Apr 27, 2006.

  1. Matt

    Matt Guest

    I have the following in a page and I am trying to update a record on
    the next page but for some reason the form data is not carrying over.
    Any ideas why?

    <form name=nxtlupdate method=post action=supers_NxtlUpdate.asp>

    <%

    Do While Not objRecordset.EOF

    Response.Write "<tr>"
    Response.Write "<td align=center valign=top><input
    type=text name=ContactName size=15 value='" &
    objRecordset("ContactName") & "'></td>"
    Response.Write "<td valign=top align=center><input
    type=text name=Radio size=4 value='" & objRecordset("Radio") &
    "'></td>"
    Response.Write "<td valign=top align=center><input
    type=text name=Mobile size=10 value='" & objRecordset("Mobile") &
    "'></td>"
    Response.Write "<td valign=top align=center><a
    href=supers_nxtlUpdate.asp?ID="
    Response.Write objRecordset("Id") & ">Update</a></td>"

    Response.Write "</tr><tr><td colspan=6><hr></td></tr><tr>"

    objRecordset.MoveNext
    Loop

    objRecordset.Close

    %>
    </form>

    ***** Second Page: *****

    <%
    dim strContactName, strRadio
    dim strMobile, strID

    strConnect = "Driver={Microsoft Access Driver (*.mdb)};
    DBQ=\\CALSJ1\PMAPPS\nextel.mdb"

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

    objRecordset.Open "tblContactList", strConnect, adOpenStatic,
    adLockOptimistic, adCmdTable

    strID = Request.QueryString("ID")

    strContactName = Request.Form("ContactName")
    strRadio = Request.Form("Radio")
    strMobile = Request.Form("Mobile")

    objRecordset.Filter = "ID='" & strID & "'"

    objRecordset("ContactName") = strContactName
    objRecordset("Radio") = strRadio
    objRecordset("Mobile") = strMobile


    objRecordset.Update
    objRecordset.Close
    set objRecordset = Nothing

    %>
     
    Matt, Apr 27, 2006
    #1
    1. Advertising

  2. Matt

    Mike Brind Guest

    Matt wrote:
    > I have the following in a page and I am trying to update a record on
    > the next page but for some reason the form data is not carrying over.
    > Any ideas why?
    >
    > <form name=nxtlupdate method=post action=supers_NxtlUpdate.asp>
    >
    > <%
    >
    > Do While Not objRecordset.EOF
    >
    > Response.Write "<tr>"
    > Response.Write "<td align=center valign=top><input
    > type=text name=ContactName size=15 value='" &
    > objRecordset("ContactName") & "'></td>"
    > Response.Write "<td valign=top align=center><input
    > type=text name=Radio size=4 value='" & objRecordset("Radio") &
    > "'></td>"
    > Response.Write "<td valign=top align=center><input
    > type=text name=Mobile size=10 value='" & objRecordset("Mobile") &
    > "'></td>"
    > Response.Write "<td valign=top align=center><a
    > href=supers_nxtlUpdate.asp?ID="
    > Response.Write objRecordset("Id") & ">Update</a></td>"
    >
    > Response.Write "</tr><tr><td colspan=6><hr></td></tr><tr>"
    >
    > objRecordset.MoveNext
    > Loop
    >
    > objRecordset.Close
    >
    > %>
    > </form>
    >
    > ***** Second Page: *****
    >
    > <%
    > dim strContactName, strRadio
    > dim strMobile, strID
    >
    > strConnect = "Driver={Microsoft Access Driver (*.mdb)};
    > DBQ=\\CALSJ1\PMAPPS\nextel.mdb"
    >
    > Set objRecordset = Server.CreateObject ("ADODB.Recordset")
    >
    > objRecordset.Open "tblContactList", strConnect, adOpenStatic,
    > adLockOptimistic, adCmdTable
    >
    > strID = Request.QueryString("ID")
    >
    > strContactName = Request.Form("ContactName")
    > strRadio = Request.Form("Radio")
    > strMobile = Request.Form("Mobile")
    >
    > objRecordset.Filter = "ID='" & strID & "'"
    >
    > objRecordset("ContactName") = strContactName
    > objRecordset("Radio") = strRadio
    > objRecordset("Mobile") = strMobile
    >
    >
    > objRecordset.Update
    > objRecordset.Close
    > set objRecordset = Nothing
    >
    > %>


    The values are not being passed because you aren't submitting the form.
    You have no <input type="submit"> anywhere.

    --
    Mike Brind
     
    Mike Brind, Apr 28, 2006
    #2
    1. Advertising

  3. Matt

    Guest

    OK, From what i can tell from your script is that you want a basic form
    to enter in new customer equiptment into a database. I can see that you
    want to enter in new data everytime you access this page, you are not
    looking to update a customer record but enter in a new record.

    You had a Request.QueryString and Request.Form when you don't need to..


    Also I am gathering that you have a database string that pulls the ID
    for objRecordSet("ID") when the page opens. If you don't have the
    database autopopulating the ID? From what i can tell you don't have it
    and that makes a big differnce. If you don't have the ID autopopulate.
    Below are two examples. One with Access populating the ID and one
    without

    You also had your access values surrounded '" & objRecordSet() & "'
    When the proper way is. only " & objRecordSet() & "


    ------------------------------ Without Auto Populate
    -------------------------------------------

    <form name=nxtlupdate method=post action=supers_NxtlUpdate.asp>
    <%
    Do While Not objRecordset.EOF
    Response.Write "<tr><td align=center valign=top><input type=text
    name=id></td></tr>"
    Response.Write "<tr><td align=center valign=top><input type=text
    name=ContactName size=15></td></tr>"
    Response.Write "<tr><td valign=top align=center><input type=text
    name=Radio size=4></td></tr>"
    Response.Write "<tr><td valign=top align=center><input type=text
    name=Mobile size=10></td></tr>"
    Response.Write "<tr><td valign=top align=center><input type=submit
    name=submit value=Update><input type=reset name=reset
    value=reset></td></tr>"
    Response.Write "<tr><td colspan=6><hr></td></tr>"
    objRecordset.MoveNext
    Loop
    objRecordset.Close
    %>
    </form>
    --------------------Next Page--------------------------
    <%
    Dim strID
    Dim strConnect
    Dim objRecordSet

    strConnect = "Driver={Microsoft Access Driver (*.mdb)};
    DBQ=\\CALSJ1\PMAPPS\nextel.mdb"
    Set objRecordset = Server.CreateObject ("ADODB.Recordset")
    objRecordset.Open "tblContactList", strConnect, adOpenStatic,
    adLockOptimistic, adCmdTable
    objRecordSet.AddNew ------------------------------- Only Add This if
    you are trying to enter a new record for each instance of a customer
    record
    strID = Request.Form("ID")

    objRecordset.Filter = "ID='" & strID & "'"
    objRecordset("ContactName") = Request.Form("ContactName")
    objRecordset("Radio") = Request.Form("Radio")
    objRecordset("Mobile") = Request.Form("Mobile")
    objRecordset.Update
    objRecordset.Close
    set objRecordset = Nothing
    %>

    ------------------------------------------ Auto Populate ID from Access
    -----------------------------------
    <form name=nxtlupdate method=post action=supers_NxtlUpdate.asp>
    <%
    Do While Not objRecordset.EOF
    Response.Write "<tr><td align=center valign=top><input type=hidden
    disabled name=id value=" & objRecordset("Id") & "></td></tr>"
    Response.Write "<tr><td align=center valign=top><input type=text
    name=ContactName size=15 value=" & objRecordset("ContactName") &
    "></td></tr>"
    Response.Write "<tr><td valign=top align=center><input type=text
    name=Radio size=4 value=" & objRecordset("Radio") & "></td></tr>"
    Response.Write "<tr><td valign=top align=center><input type=text
    name=Mobile size=10 value=" & objRecordset("Mobile") & "></td></tr>"
    Response.Write "<tr><td valign=top align=center><input type=submit
    name=submit value=Update><input type=reset name=reset
    value=reset></td></tr>"
    Response.Write "<tr><td colspan=6><hr></td></tr>"
    objRecordset.MoveNext
    Loop
    objRecordset.Close
    %>
    </form>
    --------------------Next Page--------------------------
    <%
    Dim strID
    Dim strConnect
    Dim objRecordSet

    strConnect = "Driver={Microsoft Access Driver (*.mdb)};
    DBQ=\\CALSJ1\PMAPPS\nextel.mdb"
    Set objRecordset = Server.CreateObject ("ADODB.Recordset")
    objRecordset.Open "tblContactList", strConnect, adOpenStatic,
    adLockOptimistic, adCmdTable
    objRecordSet.AddNew ------------------------------- Only Add This if
    you are trying to enter a new record for each instance of a customer
    record
    strID = Request.Form("ID")

    objRecordset.Filter = "ID='" & strID & "'"
    objRecordset("ContactName") = Request.Form("ContactName")
    objRecordset("Radio") = Request.Form("Radio")
    objRecordset("Mobile") = Request.Form("Mobile")
    objRecordset.Update
    objRecordset.Close
    set objRecordset = Nothing
    %>

    Let me know what happens?
     
    , Apr 28, 2006
    #3
  4. Matt

    Mike Brind Guest

    wrote:
    > OK, From what i can tell from your script is that you want a basic form
    > to enter in new customer equiptment into a database. I can see that you
    > want to enter in new data everytime you access this page, you are not
    > looking to update a customer record but enter in a new record.
    >


    You must have been looking at something else entirely. The OP's form
    clearly displays current data in text boxes for updating. He wants to
    be able to change existing values and pass these to the next page which
    processes an update. There is no suggestion that he is looking to add
    new records with these pages.

    If he wants to be able to update one record at a time, his second page
    should populate a form with the record associated with the ID number
    passed in the querystring, and there is no need for text boxes or a
    form on the first page. He can just write the recordset as a list or
    in a table on the first page.

    First Page:

    <%

    Do While Not objRecordset.EOF

    Response.Write "<tr>"
    Response.Write "<td align=center valign=top>" &
    objRecordset("ContactName") & "</td>"
    Response.Write "<td valign=top align=center>" &
    objRecordset("Radio") &
    "</td>"
    Response.Write "<td valign=top align=center>" &
    objRecordset("Mobile") &
    "</td>"
    Response.Write "<td valign=top align=center><a
    href=supers_nxtlUpdate.asp?ID="
    Response.Write objRecordset("Id") & ">Update</a></td>"

    Response.Write "</tr><tr><td colspan=6><hr></td></tr><tr>"
    & vbcrlf

    objRecordset.MoveNext
    Loop

    objRecordset.Close : set ObjRecordset = Nothing

    %>

    In the second page, it's not a good idea to use a recordset to perform
    an update, and dynamic sql should be avoided. He would be better
    advised to use parameters and the command object, or better yet, a
    saved parameter query.

    Open Access, and go top the Query Tab. Click New Query in Design View,
    and close the Show Tables dialogue box that appears. Switch to SQL
    view and paste this in:

    UPDATE tblContactList SET strContactName = [p1], strRadio = [p2],
    strMobile = [p3] WHERE ID = [p4];

    Save that as qUpdateContact, and then run the query. You are prompted
    for values for p1, p2 etc. Enter something sensible to make sure the
    query runs. Close Access, and in the second page do this:

    <%
    If Request.Form("Action") ="Submit" then

    p1 = Request.Form("ContactName")
    p2 = Request.Form("Radio")
    p3 = Request.Form("Mobile")
    p4 = Request.Form("ID")

    'validate values for p1 - p4

    strConnect = "Driver={Microsoft Access Driver (*.mdb)};
    DBQ=\\CALSJ1\PMAPPS\nextel.mdb"

    'or better still use the OLEDB provider:
    'strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    Source=\\CALSJ1\PMAPPS\nextel.mdb"

    set conn = Server.CreateObject("ADODB.Connection")
    conn.Open strConnect
    conn.qUpdateContact p1,p2,p3,p4
    conn.Close : set conn = Nothing

    Response.Write "Record Updated"
    Else
    ....

    'Write the form to the page, populating it with the record associated
    with the ID passed in the QueryString

    End If
    %>

    Saved parameter queries are so much easier to work with if you are
    using Access. The query is constructed, tested and debugged within the
    database, they help prevent SQL Injection attacks, and they are easier
    to maintain. If a field name needs to be changed, for example, you
    only need to do it in the database table and queries, rather than
    working through all your scripts to do so. Oh, and you get rid of all
    the problems associated with data type mismatches, and incorrectly
    delimiting datatypes in concatenated dynamic SQL statements. No
    Recordset object needs to be created, and the connection object is
    created, opened, used, closed and destroyed in the space of 4 lines.

    --
    Mike Brind
     
    Mike Brind, Apr 28, 2006
    #4
  5. Matt wrote:
    > I have the following in a page and I am trying to update a
    > record on the next page but for some reason the form data is
    > not carrying over. Any ideas why?
    >
    > <form name=nxtlupdate method=post action=supers_NxtlUpdate.asp>

    ^^^^^^^^^^^
    > strID = Request.QueryString("ID")

    ^^^^^^^^^^^^^^^^^

    When you POST, look in the Request.Form collection for the name-value pairs.



    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms.
     
    Dave Anderson, Apr 28, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jamezw

    Session not carrying over

    jamezw, Jun 21, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    437
    Bruce Barker
    Jun 21, 2005
  2. Matt Jensen

    Carrying form data between two pages

    Matt Jensen, Jul 1, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    2,484
    Matt Jensen
    Jul 4, 2005
  3. Ivan Shevanski
    Replies:
    4
    Views:
    496
    bruno modulix
    Sep 27, 2005
  4. J. Muenchbourg

    Spaces carrying over with variables in querystring

    J. Muenchbourg, Jul 26, 2003, in forum: ASP General
    Replies:
    0
    Views:
    120
    J. Muenchbourg
    Jul 26, 2003
  5. erik
    Replies:
    1
    Views:
    201
    A. Sinan Unur
    May 10, 2005
Loading...

Share This Page