Newbie: transferring values to another page!
Newbie: transferring values to another page!
am 24.05.2005 12:08:35 von Christopher W Aiken
Hi
I'm a bit out of my depth here but I have successfully managed to extract 2
pieces of information from a MySQL database; sMap & sLocation. These are
used on an asp page (below) which is located in a frame and the query is
dependent on an id provided from a cgi script!
From this page I would like to transfer these 2 values onto another asp page
which will contain a form.
I have tried running the selection query from the new 'form' page but it
can't refer to the all important 'id' querystring
I had thought I could write the values to a MySQL table and then retrieve
them on the new page
However, the INSERT INTO statement below will not work but it looks right (I
have resorted to trying to insert some text as an example). I'm guessing I'm
missing something simple! What?!
Apart from this there must be an alternative way?
Regards
Chris Curtis
<%
Dim sQuery, iMap, sMap, sLocation
iMap=Request.QueryString("id")
strConnection =
"driver={MySQL};server=127.0.0.1;database=mitre;UID=****;pas sword=****
Set adoDataConn = Server.CreateObject("ADODB.Connection")
adoDataConn.Open strConnection
sQuery = "SELECT distinctrow industrialestates.estate FROM
industrialestates INNER JOIN maps on industrialestates.serial =
maps.indestateid WHERE maps.serial = " & iMap
Set RS = adoDataConn.Execute(sQuery)
sMap = RS("estate")
sQuery = "SELECT distinctrow location.name FROM location INNER JOIN maps
on location.serial = maps.locationid WHERE maps.serial = " & iMap
Set RS = adoDataConn.Execute(sQuery)
sLocation = RS("name")
sQuery = "INSERT INTO mailingenq(estate, town) VALUES('test', 'test2')"
Set RS = adoDataConn.Execute(sQuery)
RS.Close
adoDataConn.Close
Set RS = Nothing
Set adoDataConn = Nothing
%>
Re: Newbie: transferring values to another page!
am 24.05.2005 12:38:45 von Steven Burn
Use the Querystring function
<%
'// Page1.asp
Dim strText
strText =3D "Some random text from somewhere"
Response.Redirect "page2.asp?ex=3D" & Server.URLEncode(strText)
%>
<%
'// Page2.asp
Response.Write "Text from querystring:" & =
Request.Querystring("ex")
%>
--=20
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"Chris Curtis" wrote in message =
news:u$7jNiEYFHA.3620@TK2MSFTNGP09.phx.gbl...
> Hi
>=20
> I'm a bit out of my depth here but I have successfully managed to =
extract 2=20
> pieces of information from a MySQL database; sMap & sLocation. These =
are=20
> used on an asp page (below) which is located in a frame and the query =
is=20
> dependent on an id provided from a cgi script!
> From this page I would like to transfer these 2 values onto another =
asp page=20
> which will contain a form.
> I have tried running the selection query from the new 'form' page but =
it=20
> can't refer to the all important 'id' querystring
>=20
> I had thought I could write the values to a MySQL table and then =
retrieve=20
> them on the new page
>=20
> However, the INSERT INTO statement below will not work but it looks =
right (I=20
> have resorted to trying to insert some text as an example). I'm =
guessing I'm=20
> missing something simple! What?!
>=20
> Apart from this there must be an alternative way?
>=20
> Regards
> Chris Curtis
>=20
> <%
>=20
> Dim sQuery, iMap, sMap, sLocation
>=20
> iMap=3DRequest.QueryString("id")
>=20
> strConnection =
> =
"driver=3D{MySQL};server=3D127.0.0.1;database=3Dmitre;UID=3D ****;password=
=3D****
> Set adoDataConn =3D Server.CreateObject("ADODB.Connection")
> adoDataConn.Open strConnection
>=20
> sQuery =3D "SELECT distinctrow industrialestates.estate FROM=20
> industrialestates INNER JOIN maps on industrialestates.serial =
> maps.indestateid WHERE maps.serial =3D " & iMap
>=20
> Set RS =3D adoDataConn.Execute(sQuery)
>=20
> sMap =3D RS("estate")
>=20
> sQuery =3D "SELECT distinctrow location.name FROM location INNER =
JOIN maps=20
> on location.serial =3D maps.locationid WHERE maps.serial =3D " & iMap
>=20
> Set RS =3D adoDataConn.Execute(sQuery)
>=20
> sLocation =3D RS("name")
>=20
> sQuery =3D "INSERT INTO mailingenq(estate, town) VALUES('test', =
'test2')"
>=20
> Set RS =3D adoDataConn.Execute(sQuery)
>=20
> RS.Close
>=20
> adoDataConn.Close
>=20
> Set RS =3D Nothing
> Set adoDataConn =3D Nothing
>=20
> %>
>=20
>=20
Re: Newbie: transferring values to another page!
am 24.05.2005 12:46:33 von reb01501
Chris Curtis wrote:
> Hi
>
> I'm a bit out of my depth here but I have successfully managed to
> extract 2 pieces of information from a MySQL database; sMap &
> sLocation. These are used on an asp page (below) which is located in
> a frame and the query is dependent on an id provided from a cgi
> script! From this page I would like to transfer these 2 values onto
> another
> asp page which will contain a form.
> I have tried running the selection query from the new 'form' page but
> it can't refer to the all important 'id' querystring
>
> I had thought I could write the values to a MySQL table and then
> retrieve them on the new page
Not necessary. You can use Session variables, or querystring.
>
> However, the INSERT INTO statement below will not work
What does "will not work" mean? error messages? Incorrect results? Nothing
happens? We cannot help you if you don't describe your symptoms!
> but it looks
> right (I have resorted to trying to insert some text as an example).
> I'm guessing I'm missing something simple! What?!
>
> Apart from this there must be an alternative way?
>
> Regards
> Chris Curtis
>
> <%
>
> Dim sQuery, iMap, sMap, sLocation
>
> iMap=Request.QueryString("id")
>
> strConnection =
> "driver={MySQL};server=127.0.0.1;database=mitre;UID=****;pas sword=****
> Set adoDataConn = Server.CreateObject("ADODB.Connection")
> adoDataConn.Open strConnection
>
> sQuery = "SELECT distinctrow industrialestates.estate FROM
> industrialestates INNER JOIN maps on industrialestates.serial =
> maps.indestateid WHERE maps.serial = " & iMap
>
> Set RS = adoDataConn.Execute(sQuery)
>
> sMap = RS("estate")
>
> sQuery = "SELECT distinctrow location.name FROM location INNER JOIN
> maps on location.serial = maps.locationid WHERE maps.serial = " & iMap
>
> Set RS = adoDataConn.Execute(sQuery)
>
> sLocation = RS("name")
>
> sQuery = "INSERT INTO mailingenq(estate, town) VALUES('test',
> 'test2')"
> Set RS = adoDataConn.Execute(sQuery)
This may not causing your problem [1], but an INSERT query DOES NOT RETURN
RECORDS! It is extrememly wasteful to allow ADO to create a recordset when
you know your query is not returning records. A non-records-returning query
should be executed without a recordset, and you should tell ADO not to
bother creating a recordset object in the background (which it does by
default)
'if you've included the adovbs.inc file, or used a meta tag
'to reference the ADO type library, these two lines will
'not be needed:
const adCmdText=1
const adExecNoRecords
adoDataConn.Execute sQuery,,adCmdText + adExecNoRecords
You should stop using dynamic sql. Try out this technique:
http://groups-beta.google.com/group/microsoft.public.inetser ver.asp.db/msg/72e36562fee7804e
[1] however, in some cases, attempting to reuse a recordset object without
closing it first can cause errors.
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Re: Newbie: transferring values to another page!
am 24.05.2005 12:58:59 von reb01501
Bob Barrows [MVP] wrote:
> const adExecNoRecords
Oops, I forgot to finish this statement. It should be:
const adExecNoRecords=128
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Re: Newbie: transferring values to another page!
am 24.05.2005 15:35:44 von Christopher W Aiken
"Bob Barrows [MVP]" wrote in message
news:%23zb1X%23EYFHA.2380@tk2msftngp13.phx.gbl...
> Bob Barrows [MVP] wrote:
>> const adExecNoRecords
>
> Oops, I forgot to finish this statement. It should be:
>
> const adExecNoRecords=128
>
> Bob Barrows
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
Thank you both for those responses!
I'm not sure I fully understand all the content but will 'have a go'
I don't suppose anyoine knows where our programer went who dropped me in
this mess!
Chris
Re: Newbie: transferring values to another page!
am 24.05.2005 16:48:58 von Mark Schupp
If the values are fairly short just include them and the id in the link used
to jump to the page with the form on it.
--
--Mark Schupp
"Chris Curtis" wrote in message
news:u$7jNiEYFHA.3620@TK2MSFTNGP09.phx.gbl...
> Hi
>
> I'm a bit out of my depth here but I have successfully managed to extract
> 2 pieces of information from a MySQL database; sMap & sLocation. These are
> used on an asp page (below) which is located in a frame and the query is
> dependent on an id provided from a cgi script!
> From this page I would like to transfer these 2 values onto another asp
> page which will contain a form.
> I have tried running the selection query from the new 'form' page but it
> can't refer to the all important 'id' querystring
>
> I had thought I could write the values to a MySQL table and then retrieve
> them on the new page
>
> However, the INSERT INTO statement below will not work but it looks right
> (I have resorted to trying to insert some text as an example). I'm
> guessing I'm missing something simple! What?!
>
> Apart from this there must be an alternative way?
>
> Regards
> Chris Curtis
>
> <%
>
> Dim sQuery, iMap, sMap, sLocation
>
> iMap=Request.QueryString("id")
>
> strConnection =
> "driver={MySQL};server=127.0.0.1;database=mitre;UID=****;pas sword=****
> Set adoDataConn = Server.CreateObject("ADODB.Connection")
> adoDataConn.Open strConnection
>
> sQuery = "SELECT distinctrow industrialestates.estate FROM
> industrialestates INNER JOIN maps on industrialestates.serial =
> maps.indestateid WHERE maps.serial = " & iMap
>
> Set RS = adoDataConn.Execute(sQuery)
>
> sMap = RS("estate")
>
> sQuery = "SELECT distinctrow location.name FROM location INNER JOIN maps
> on location.serial = maps.locationid WHERE maps.serial = " & iMap
>
> Set RS = adoDataConn.Execute(sQuery)
>
> sLocation = RS("name")
>
> sQuery = "INSERT INTO mailingenq(estate, town) VALUES('test', 'test2')"
>
> Set RS = adoDataConn.Execute(sQuery)
>
> RS.Close
>
> adoDataConn.Close
>
> Set RS = Nothing
> Set adoDataConn = Nothing
>
> %>
>
>
Re: Newbie: transferring values to another page!
am 24.05.2005 17:02:48 von Christopher W Aiken
"Steven Burn" wrote in message
news:uV98fzEYFHA.612@TK2MSFTNGP12.phx.gbl...
Use the Querystring function
<%
'// Page1.asp
Dim strText
strText = "Some random text from somewhere"
Response.Redirect "page2.asp?ex=" & Server.URLEncode(strText)
%>
<%
'// Page2.asp
Response.Write "Text from querystring:" &
Request.Querystring("ex")
%>
Hi Steve
For the moment on the same page I have stripped out all the MySQL stuff and
added the following: (see below).
All I get is The page cannot be displayed which was the message I was
referring to earlier when I said it didn't work!
Strangely, even when I grey the 3 lines out it still doesn't display.
Only when I remove them does it display!
I've not got to the second page yet!
Chris
<%
@LANGUAGE = VBScript
Dim strText
strText = "Test Text"
Response.Redirect "mailenq.asp?ex=" & Server.URLEncode(strText)
%>
........... etc
Re: Newbie: transferring values to another page!
am 24.05.2005 17:19:47 von reb01501
Chris Curtis wrote:
>
> For the moment on the same page I have stripped out all the MySQL
> stuff and added the following: (see below).
> All I get is The page cannot be displayed which was the message I was
Remember what I said yesterday about fully describing your symptoms? This
could have been resolved already ...
You need to see the real error message:
http://www.aspfaq.com/show.asp?id=2109
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Re: Newbie: transferring values to another page!
am 24.05.2005 17:23:34 von reb01501
Chris Curtis wrote:
> <%
> @LANGUAGE = VBScript
>
> Dim strText
> strText = "Test Text"
> Response.Redirect "mailenq.asp?ex=" & Server.URLEncode(strText)
> %>
>
>
>
........... etc
Oh! And the problem here is the @ directive needs to be in its own block:
<%@LANGUAGE = VBScript%>
<%
Dim strText
strText = "Test Text"
Response.Redirect "mailenq.asp?ex=" & Server.URLEncode(strText)
%>
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Re: Newbie: transferring values to another page!
am 24.05.2005 18:09:06 von Christopher W Aiken
"Mark Schupp" wrote in message
news:e7Cw2BHYFHA.3572@TK2MSFTNGP12.phx.gbl...
> If the values are fairly short just include them and the id in the link
> used to jump to the page with the form on it.
>
That worked thank you.
Chris
Re: Newbie: transferring values to another page!
am 24.05.2005 18:10:40 von Christopher W Aiken
"Bob Barrows [MVP]" wrote in message
news:etKqGQHYFHA.2884@tk2msftngp13.phx.gbl...
>
> You need to see the real error message:
> http://www.aspfaq.com/show.asp?id=2109
>
>
You live and learn!
Thank you!
Re: Newbie: transferring values to another page!
am 24.05.2005 18:56:47 von Kyle Peterson
forms and querystrings
http://www.powerasp.com/content/hintstips/asp-forms.asp
"Chris Curtis" wrote in message
news:u$7jNiEYFHA.3620@TK2MSFTNGP09.phx.gbl...
> Hi
>
> I'm a bit out of my depth here but I have successfully managed to extract
> 2 pieces of information from a MySQL database; sMap & sLocation. These are
> used on an asp page (below) which is located in a frame and the query is
> dependent on an id provided from a cgi script!
> From this page I would like to transfer these 2 values onto another asp
> page which will contain a form.
> I have tried running the selection query from the new 'form' page but it
> can't refer to the all important 'id' querystring
>
> I had thought I could write the values to a MySQL table and then retrieve
> them on the new page
>
> However, the INSERT INTO statement below will not work but it looks right
> (I have resorted to trying to insert some text as an example). I'm
> guessing I'm missing something simple! What?!
>
> Apart from this there must be an alternative way?
>
> Regards
> Chris Curtis
>
> <%
>
> Dim sQuery, iMap, sMap, sLocation
>
> iMap=Request.QueryString("id")
>
> strConnection =
> "driver={MySQL};server=127.0.0.1;database=mitre;UID=****;pas sword=****
> Set adoDataConn = Server.CreateObject("ADODB.Connection")
> adoDataConn.Open strConnection
>
> sQuery = "SELECT distinctrow industrialestates.estate FROM
> industrialestates INNER JOIN maps on industrialestates.serial =
> maps.indestateid WHERE maps.serial = " & iMap
>
> Set RS = adoDataConn.Execute(sQuery)
>
> sMap = RS("estate")
>
> sQuery = "SELECT distinctrow location.name FROM location INNER JOIN maps
> on location.serial = maps.locationid WHERE maps.serial = " & iMap
>
> Set RS = adoDataConn.Execute(sQuery)
>
> sLocation = RS("name")
>
> sQuery = "INSERT INTO mailingenq(estate, town) VALUES('test', 'test2')"
>
> Set RS = adoDataConn.Execute(sQuery)
>
> RS.Close
>
> adoDataConn.Close
>
> Set RS = Nothing
> Set adoDataConn = Nothing
>
> %>
>
>
Re: Newbie: transferring values to another page!
am 29.05.2005 22:33:09 von Jon
If you are having problems using the code posted from Chris Curtis a
solution may be below ... especially if using Option Explicit. I had
problems and found a solutiong (Eventually).
Reference the ADO Library like so: (Not ASP code outside the <% %>)
And then declare the constants:
CONST adCmdText = &H0001
CONST adExecuteNoRecords = &H00000080
A complete list of the constant values can be found here:
http://asp.programmershelp.co.uk/adoconstants.php
--
Jon
warpedpixel@gmail.com
Look at that dead pixel on your screen! *SLAP* Gotcha!
Re: Newbie: transferring values to another page!
am 30.05.2005 00:23:42 von Steven Burn
> Reference the ADO Library like so: (Not ASP code outside the <% %>)
>
There's something very wrong if you need to include this......
> And then declare the constants:
> CONST adCmdText =3D &H0001
> CONST adExecuteNoRecords =3D &H00000080
Why would you need this for non-DB related events?
--=20
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"Jon" wrote in message =
news:#9Ahi2IZFHA.3040@TK2MSFTNGP14.phx.gbl...
> If you are having problems using the code posted from Chris Curtis a=20
> solution may be below ... especially if using Option Explicit. I had=20
> problems and found a solutiong (Eventually).
>=20
> Reference the ADO Library like so: (Not ASP code outside the <% %>)
>
>=20
> And then declare the constants:
> CONST adCmdText =3D &H0001
> CONST adExecuteNoRecords =3D &H00000080
>=20
> A complete list of the constant values can be found here:
> http://asp.programmershelp.co.uk/adoconstants.php
>=20
> --=20
> Jon
> warpedpixel@gmail.com
> Look at that dead pixel on your screen! *SLAP* Gotcha!=20
>=20
>=20