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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable

Status
Not open for further replies.

taoist

Programmer
Joined
Feb 1, 2006
Messages
35
Location
US
I would like to set variable to this recordset
can someone help me with this issue

<%=(Recordset1.Fields.Item("first").Value)%>

Here is the rest of code

<p><font class="headline"><span class="style5">Welcome: </span><strong><span class="style9"><%=(Recordset1.Fields.Item("first").Value)%></span></strong></font>
 
did you mean this:

if it is a single value

dim myvar
myvar=Recordset1.Fields.Item("first").Value

if your recordset has many values then

dim myvar
myvar=""
if Recordset1.EOF and Recordset1.BOF then
response.write "no records found"
else
do until Recordset1.EOF
myvar=myvar & "," & Recordset1.Fields.Item("first").Value
Recordset1.movenext
loop
response.write myvar

-DNG
 
That works great.. Another question
How would I send the variable to another page.

I have a link called

My Link

Once I click the link it goes to another page

can it carry the variable value to the next page.

any help on this would be greatly appreciated
 
yes...store the variable inside a session or pass it in the querystring...

as a session variable...
Code:
session("myvar")=myvar
then on the next page you can check
response.write session("myvar")

as a query string parameter...
Code:
<a href="mylinkpage.asp?myvariable="&myvar>my link</a>

-DNG
 
with the query string. How do I set that to a object like a
recordset or a textbox on the mylinkpage.asp
 
did not understand your connection completely...can you explain what you are actually trying to do...

-DNG
 
If the variable is passed to mylinkpage.asp

How can I set that variable to a recordset
on mylinkpage.asp

here is the recordset on mylinkpage
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_Helpdeskcnn_STRING
Recordset1.Source = "SELECT * FROM dbo.login WHERE first = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
 
something is wrong with my syntax

<td valign="top" class="text"><a href="main1.asp?myvar=" myvar> My Tasks</a>
 
<td valign="top" class="text"><a href="main1.asp?myvar="[red]&[/red] myvar> My Tasks</a>

-DNG
 
and if you want to pass the whole recordset as a variable then use the getrows() method and create an array with the complete recordset and then pass it as a parameter in the querystring...

-DNG
 
it should work...try it out...

<td valign="top" class="text"><a href="main1.asp?myvar="& myvar> My Tasks</a>

or

<td valign="top" class="text"><a href="main1.asp?myvar="& myvar&" "> My Tasks</a>

-DNG
 
no I don't want to pass the recordset. just the variable.

Then on mylinkpage.asp it has a recordset. This is where I want to set that variable in the recordset.

The variable is carry data that needs to be placed in the query

Recordset1.Source = "SELECT * FROM dbo.login WHERE first = '" + Replace(myvar, "'", "''") + "'"

something like this I quess
but I'm not sure
 
These do not work

<td valign="top" class="text"><a href="main1.asp?myvar="& myvar> My Tasks</a>

or

<td valign="top" class="text"><a href="main1.asp?myvar="& myvar&" "> My Tasks</a>
 
sorry...i was thinking that you were doing inside a response.write...try this:

<td valign="top" class="text"><a href="main1.asp?myvariable=<%=myvar%>"> My Tasks</a>

-DNG
 
ok...works great.

Know I can place this varibale in a recordset
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top