Problem with Response.Redirect
From: Jack (Jack_at_discussions.microsoft.com)
Date: 02/22/05
- Next message: Steven Burn: "Re: Problem with Response.Redirect"
- Previous message: middletree: "Re: connection string--setup problems"
- Next in thread: Steven Burn: "Re: Problem with Response.Redirect"
- Reply: Steven Burn: "Re: Problem with Response.Redirect"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 22 Feb 2005 09:13:04 -0800
Hello,
I am testing a simple asp page. Here data is added to a database in People
table.
The primary key is Name (FirstName LastName). The data add part is working
fine. However, after one data is added, I need to redirect the page back to
the same record that was entered in the form. I am capturing the primary
key(here it is name from the Request.Form command).
However, data is being added to the table but the response.redirect
statement is
giving an error. For example, if I add a data with Name as Jack Jones along
with
other fields, the error message I am getting is as follows:
http://localhost/gwisbrandnewready4/test/textdisable.asp.asp?l_Name=Jack%20Jones
with 'Page Not Found' error.
Here, it seems the space between Jack Jones is creating a problem.
Any help is appreciated in advance. Thanks.
CODE:
<%@ Language=VBScript %>
<%
'The following line is to prevent this page coming from history.
'We need a new page fro the server each time so that all the
'session variables are reset
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<P> </P>
<%
'myDSN="DRIVER={Microsoft Access Driver (*.mdb)}; "
'myDSN=myDSN & "DBQ=C:\_______GWISBRANDNEWREADY4\test\disabletext.mdb"
myDSN="Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\_______GWISBRANDNEWREADY4\test\disabletext.mdb"
set CN=server.createobject("ADODB.Connection")
CN.Open myDSN
'pRS stands for recordset corresponding to the current people detail
set pRS=server.createobject("ADODB.Recordset")
pRS.ActiveConnection = CN
'Define local variables to hold values written on form
Dim l_Name
Dim l_ColorPreference
Dim l_Age
Dim l_IsChecked
'Store the input values in the form to the above defined variable
l_Name = Request.Form("txtName")
l_ColorPreference = Request.Form("txtColorPreference")
l_Age = Request.Form("txtAge")
l_IsChecked = Request.Form("chkConsent")
if l_IsChecked = "" Then
l_IsChecked = "off"
End If
'Get the values on screen for scrutiny
'Response.Write l_name & "<br>"
'Response.Write l_ColorPreference & "<br>"
'Response.Write l_Age & "<br>"
'Response.Write l_IsChecked & "<br>"
SQL = "INSERT INTO People(name,colorpreference, age, ischecked) VALUES
('"&l_Name&"','"&l_ColorPreference&"',"&l_Age&", "&l_IsChecked&")"
'Response.Write SQL
CN.Execute SQL
'Issue a statement stating that the update has been successful
'Response.Write("Your record has been added to the database")
'Response.Redirect ("textdisable.asp")
Response.Redirect("textdisable.asp.asp?l_Name=" & l_Name)
%>
</BODY>
</HTML>
l_Name
- Next message: Steven Burn: "Re: Problem with Response.Redirect"
- Previous message: middletree: "Re: connection string--setup problems"
- Next in thread: Steven Burn: "Re: Problem with Response.Redirect"
- Reply: Steven Burn: "Re: Problem with Response.Redirect"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|