Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass parameter from hyperlink (novice)

Status
Not open for further replies.

MDA

Technical User
Jan 16, 2001
243
US
Hi all,

I have what seems to be a simple question. However, I can't find much online info on this question.

I have two pages the 1st has hyperlinks to an asp page. the hyperlink is passing a parameter:
Ex: ...=&quot; target=&quot;_blank&quot;>See account table:</a>
This is passing the FIELD parameter with value acconame (i hope)

The ASP page has simple syntax like this:
Page 2-------------------
<% set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Conn.open &quot;MyDB&quot;, &quot;user&quot; ,&quot;&quot;
SQL=&quot;SELECT ::Field:: from acco &quot;
set RS = Conn.Execute(SQL)
%>

<P>
<TABLE BORDER=1>
<TR>
<% For i = 0 to RS.Fields.Count - 1 %>
<TD><B><%= RS(i).Name %></B></TD>
<% Next %>
</TR>
<% DO While Not RS.EOF %>
<TR>
<% For i = 0 to RS.Fields.Count - 1 %>
<TD VALIGN=TOP>
<%= RS(i) %>
</TD>
<% Next %>
</TR>
<%
RS.MoveNext
Loop
RS.Close
Conn.Close
%>
</Table>

------------------

My questions is in regards to the SQL syntax. If I &quot;hard code&quot; the SQL, it works fine, but when I try to call in the parameter, it does not work.

I got the idea of using the ::parameter:: from MS Frontpage, but have no clue if this is correct syntax.

Any thoughts on how to pass and then call a variable(parameter) I would appreciate it.

Regards,
Mike
 
to retrieve a value named field from the querystring:

field = Request.QueryString(&quot;field&quot;)

now stored in field will be:acconame jaredn@eae.net -
 
To clarify further,

You're missing one step:
You must pass the parameter in the hyperlink, and then you must Request it with querystring.

The variable (Field) is unknown to your ASP page until you use: field = Request.Querystring(&quot;field&quot;)

After that, you can then use field in your code.
 
Once you do that, you need to concatenate it into the sql statement, something like:

[tt]field = Request.Querystring(&quot;field&quot;)

sql = &quot;SELECT [FIELD] FROM database WHERE field = &quot; & field[/tt]

This is from memory but should be close.

Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top