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

Variable disappears when cursor closes

Status
Not open for further replies.

pdbowling

Programmer
Mar 28, 2003
267
0
0
US
Hello, everyone.

I am setting a variable equal to a data point in a cursor row. Snippet below.
Is there a way to get a persistent variable assignment to the variable 'id'?
This is clearing out when I close the cursor.
I know that it is getting set from the cursor since it is showing in the input text box.

Code:
    DBOpen()
    sql="SELECT MAX(event_id)+1 event_id FROM nr_phy_event_tracking "
    cursor=DBQuery(sql)

    Write("<TABLE class='queueTable' align=center>")
    id = cursor("event_id")
    Write("<TR><TH class=style1>Event ID:<TD><input type='text' id='txtID' value='" + id + "'/>")
    cursor.Close
    Write("." + id + ".") //prints ..

Thanks, Everyone.
Patrick
 
are you sure that is javascript? doesn't look like it to me.
 
DBOpen() is a function I wrote, as is DBQuery().

Write() is Response.Write().

This is an .asp page with
Code:
<%@ Language=JavaScript %>
<SCRIPT RUNAT=SERVER Language="JavaScript" src="ServerUtils.js"></SCRIPT>
at the top.
 
I solved this.

It seems that direct assignment of a record data point to a variable creates a reference copy of the data point.

Cast it to a data type, and it will persist instead of evaporating when the record set is closed.

Code:
myVariable =  String(curs("UserID"))
 
Ok, I will buy that it is not Javascript even though I google Javascript when I need sample code.

So given that it is not Javascript and with this at the top
Code:
<%@ Language=JavaScript %>
<% Response.Expires=0 %>
<SCRIPT RUNAT=SERVER Language="JavaScript" src="ServerUtils.js"></SCRIPT>
<SCRIPT Language="JavaScript" src="ClientUtils.js"></SCRIPT>
<HTML>
<HEAD>
<LINK REL="stylesheet" TYPE="text/css" HREF="Styles.css">
</HEAD>
<BODY onload='SelectFirstField()'>
<% //my code is here %>

what is the code in so that I might refer to it correctly?? I thought asp pages could run JavaScript.

Thanks,
Patrick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top