Problem with Response.Redirect

From: Jack (Jack_at_discussions.microsoft.com)
Date: 02/22/05


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



Relevant Pages

  • Re: Establish connection with and transferring data to Access
    ... If you Google for SQL +"Insert into" you'll a dozen tutorials. ... The specific problem with your code is that you need to quote string ... Dim vConnection As New ADODB.Connection ... Doug's code opens and writes to an existing database. ...
    (microsoft.public.word.vba.general)
  • Re: WHERE statement syntax
    ... which is what database you're using. ... SQL syntax for dates, but I'll just cover the gamut and you can decide based ... > Dim myConnString ... > myConnString = Application ...
    (microsoft.public.frontpage.programming)
  • Re: Error Message: Two few parameters, Expected 2
    ... reasons the records are not saving properly to the database. ... Here the sql statement is referencing the form for the susgrant ... >> Dim rst As Recordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: Accesss ADP
    ... different name, upload it to the server, and when it was finished uploading, ... so that it would overwrite the original database ... I know that there's a SQL button somewhere in there. ... It doesn't have to be a primary key - ...
    (comp.databases.ms-sqlserver)
  • Re: How to read data from stand alone SQL CE database on mobile device from VB.net 2005
    ... also use Rapi to delete the file on the device when you're finished with it. ... I have a stand alone SQL CE database on my windows mobile device. ... Dim conn As New SqlCeConnection("Data Source=\My ...
    (microsoft.public.sqlserver.ce)