By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,978 Members | 1,362 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,978 IT Pros & Developers. It's quick & easy.

Form Data not carrying over???

P: n/a
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

%>

Apr 27 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

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

Apr 28 '06 #2

P: n/a
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 '06 #3

P: n/a

nv*********@caitele.com 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

Apr 28 '06 #4

P: n/a
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.
Apr 28 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.