Problem with Response.Redirect

Problem with Response.Redirect

am 22.02.2005 18:13:04 von jack

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"
%>







<%

'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 & "
"
'Response.Write l_ColorPreference & "
"
'Response.Write l_Age & "
"
'Response.Write l_IsChecked & "
"

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)
%>


l_Name

Re: Problem with Response.Redirect

am 22.02.2005 18:33:19 von Steven Burn

Change;

Response.Redirect("textdisable.asp.asp?l_Name=3D" & l_Name)

To

Response.Redirect("textdisable.asp?l_Name=3D" & l_Name)

--=20
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

"Jack" wrote in message =
news:7B1B8EED-4671-401A-A949-CE1BB7A13506@microsoft.com...
> Hello,=20
> I am testing a simple asp page. Here data is added to a database in =
People=20
> table.
> The primary key is Name (FirstName LastName). The data add part is =
working=20
> fine. However, after one data is added, I need to redirect the page =
back to=20
> the same record that was entered in the form. I am capturing the =
primary=20
> key(here it is name from the Request.Form command).
> However, data is being added to the table but the response.redirect=20
> statement is=20
> giving an error. For example, if I add a data with Name as Jack Jones =
along=20
> with=20
> other fields, the error message I am getting is as follows:
>=20
> =
http://localhost/gwisbrandnewready4/test/textdisable.asp.asp ?l_Name=3DJac=
k%20Jones
>=20
> with 'Page Not Found' error.
> Here, it seems the space between Jack Jones is creating a problem.
>=20
> Any help is appreciated in advance. Thanks.=20
>=20
> CODE:
>=20
> <%@ Language=3DVBScript %>
> <%
> '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 =3D "no-cache"
> Response.AddHeader "Pragma", "no-cache"
> %>
>
>
>
>
>
>=20
>


> <%
>=20
> 'myDSN=3D"DRIVER=3D{Microsoft Access Driver (*.mdb)}; "
> 'myDSN=3DmyDSN & =
"DBQ=3DC:\_______GWISBRANDNEWREADY4\test\disabletext.mdb"
>=20
> myDSN=3D"Provider=3DMicrosoft.Jet.OLEDB.4.0;" & _
> "Data Source=3DC:\_______GWISBRANDNEWREADY4\test\disabletext.mdb"
>=20
>=20
> set CN=3Dserver.createobject("ADODB.Connection")
> CN.Open myDSN
> 'pRS stands for recordset corresponding to the current people detail
> set pRS=3Dserver.createobject("ADODB.Recordset")
> pRS.ActiveConnection =3D CN
> 'Define local variables to hold values written on form
>=20
> Dim l_Name
> Dim l_ColorPreference
> Dim l_Age
> Dim l_IsChecked
>=20
> 'Store the input values in the form to the above defined variable
>=20
> l_Name =3D Request.Form("txtName")
> l_ColorPreference =3D Request.Form("txtColorPreference")
> l_Age =3D Request.Form("txtAge")
> l_IsChecked =3D Request.Form("chkConsent")
> if l_IsChecked =3D "" Then
> l_IsChecked =3D "off"
> End If
>=20
> 'Get the values on screen for scrutiny
> 'Response.Write l_name & "
"
> 'Response.Write l_ColorPreference & "
"
> 'Response.Write l_Age & "
"
> 'Response.Write l_IsChecked & "
"
>=20
> SQL =3D "INSERT INTO People(name,colorpreference, age, ischecked) =
VALUES=20
> ('"&l_Name&"','"&l_ColorPreference&"',"&l_Age&", "&l_IsChecked&")"=20
> 'Response.Write SQL
>=20
> CN.Execute SQL
>=20
>=20
> '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=3D" & l_Name)
> %>
>
>
> l_Name
>=20
>=20

Re: Problem with Response.Redirect

am 22.02.2005 18:51:15 von jack

Thanks Steven for your help. With the change I made, now the data entry page
is displayed with blank record. My intention is to go back to the record of
Jack Jones.
The url of the page redirected to is now:
http://localhost/gwisbrandnewready4/test/textdisable.asp?l_N ame=Jack%20Jones
I am wondering why the page of Jack Jones, which got addes is not being
retrieved in the process of redirect. Thanks.
Regards.
"Steven Burn" wrote:

> Change;
>
> Response.Redirect("textdisable.asp.asp?l_Name=" & l_Name)
>
> To
>
> Response.Redirect("textdisable.asp?l_Name=" & l_Name)
>
> --
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
> "Jack" wrote in message news:7B1B8EED-4671-401A-A949-CE1BB7A13506@microsoft.com...
> > 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"
> > %>
> >
> >
> >
> >
> >
> >
> >


> > <%
> >
> > '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 & "
"
> > 'Response.Write l_ColorPreference & "
"
> > 'Response.Write l_Age & "
"
> > 'Response.Write l_IsChecked & "
"
> >
> > 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)
> > %>
> >
> >
> > l_Name
> >
> >
>
>

Re: Problem with Response.Redirect

am 22.02.2005 19:00:33 von Steven Burn

Because the name is being passed as a querystring and not a form field =
(Request.Form() will not catch querystrings, you need to use =
Request.QueryString() for that)

e.g.

<%
l_Name =3D Request.Querystring("l_Name")
If Len(l_Name) < 1 Then l_Name =3D Request.Form("l_Name")
Response.Write l_Name
%>

--=20
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

"Jack" wrote in message =
news:01AD88A1-BB76-4522-BAC3-567330CBBE05@microsoft.com...
> Thanks Steven for your help. With the change I made, now the data =
entry page=20
> is displayed with blank record. My intention is to go back to the =
record of=20
> Jack Jones.
> The url of the page redirected to is now:
> =
http://localhost/gwisbrandnewready4/test/textdisable.asp?l_N ame=3DJack%20=
Jones
> I am wondering why the page of Jack Jones, which got addes is not =
being=20
> retrieved in the process of redirect. Thanks.=20
> Regards.
> "Steven Burn" wrote:
>=20
> > Change;
> >=20
> > Response.Redirect("textdisable.asp.asp?l_Name=3D" & l_Name)
> >=20
> > To
> >=20
> > Response.Redirect("textdisable.asp?l_Name=3D" & l_Name)
> >=20
> > --=20
> > Regards
> >=20
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >=20
> > Keeping it FREE!
> >=20
> > "Jack" wrote in message =
news:7B1B8EED-4671-401A-A949-CE1BB7A13506@microsoft.com...
> > > Hello,=20
> > > I am testing a simple asp page. Here data is added to a database =
in People=20
> > > table.
> > > The primary key is Name (FirstName LastName). The data add part is =
working=20
> > > fine. However, after one data is added, I need to redirect the =
page back to=20
> > > the same record that was entered in the form. I am capturing the =
primary=20
> > > key(here it is name from the Request.Form command).
> > > However, data is being added to the table but the =
response.redirect=20
> > > statement is=20
> > > giving an error. For example, if I add a data with Name as Jack =
Jones along=20
> > > with=20
> > > other fields, the error message I am getting is as follows:
> > >=20
> > > =
http://localhost/gwisbrandnewready4/test/textdisable.asp.asp ?l_Name=3DJac=
k%20Jones
> > >=20
> > > with 'Page Not Found' error.
> > > Here, it seems the space between Jack Jones is creating a problem.
> > >=20
> > > Any help is appreciated in advance. Thanks.=20
> > >=20
> > > CODE:
> > >=20
> > > <%@ Language=3DVBScript %>
> > > <%
> > > '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 =3D "no-cache"
> > > Response.AddHeader "Pragma", "no-cache"
> > > %>
> > >
> > >
> > >
> > >
> > >
> > >=20
> > >


> > > <%
> > >=20
> > > 'myDSN=3D"DRIVER=3D{Microsoft Access Driver (*.mdb)}; "
> > > 'myDSN=3DmyDSN & =
"DBQ=3DC:\_______GWISBRANDNEWREADY4\test\disabletext.mdb"
> > >=20
> > > myDSN=3D"Provider=3DMicrosoft.Jet.OLEDB.4.0;" & _
> > > "Data Source=3DC:\_______GWISBRANDNEWREADY4\test\disabletext.mdb"
> > >=20
> > >=20
> > > set CN=3Dserver.createobject("ADODB.Connection")
> > > CN.Open myDSN
> > > 'pRS stands for recordset corresponding to the current people =
detail
> > > set pRS=3Dserver.createobject("ADODB.Recordset")
> > > pRS.ActiveConnection =3D CN
> > > 'Define local variables to hold values written on form
> > >=20
> > > Dim l_Name
> > > Dim l_ColorPreference
> > > Dim l_Age
> > > Dim l_IsChecked
> > >=20
> > > 'Store the input values in the form to the above defined variable
> > >=20
> > > l_Name =3D Request.Form("txtName")
> > > l_ColorPreference =3D Request.Form("txtColorPreference")
> > > l_Age =3D Request.Form("txtAge")
> > > l_IsChecked =3D Request.Form("chkConsent")
> > > if l_IsChecked =3D "" Then
> > > l_IsChecked =3D "off"
> > > End If
> > >=20
> > > 'Get the values on screen for scrutiny
> > > 'Response.Write l_name & "
"
> > > 'Response.Write l_ColorPreference & "
"
> > > 'Response.Write l_Age & "
"
> > > 'Response.Write l_IsChecked & "
"
> > >=20
> > > SQL =3D "INSERT INTO People(name,colorpreference, age, ischecked) =
VALUES=20
> > > ('"&l_Name&"','"&l_ColorPreference&"',"&l_Age&", "&l_IsChecked&")" =

> > > 'Response.Write SQL
> > >=20
> > > CN.Execute SQL
> > >=20
> > >=20
> > > '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=3D" & l_Name)
> > > %>
> > >
> > >
> > > l_Name
> > >=20
> > >=20
> >=20
> >