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!

ADODB.Field (0x80020009), Object is no longer valid. - Help? 1

Status
Not open for further replies.

other3

Programmer
Joined
Jul 30, 2002
Messages
92
Location
US
I am using the following JavaScript to fill in an HTML form.
The problem is I am getting the following error:

Error Type:
ADODB.Field (0x80020009)
Object is no longer valid.
/currentMag.asp, line 107

Which is this line - Response.Write(magObj.getPersonOnCover());

Would appreciate help?

I know the record is being retrieved since if I put a Response.Write(this.oneOfTheFields) in the getMagazine() function prior to objRS.close(), the correct info is displayed.

Thanks in advance. Charlie

<%
function magazineObj(month, year)
{
// constructor parameters

this.month = month;
this.year = year;

// Object Variables

this.datePublished;
this.yearPublished;
this.MonthPublished;
this.Volume;
this.editionNumber;
this.cover;
this.condition;
this.miscellanous;
this.personOnCover;
this.needsReplaced;

// Methods

this.getMagazine = getMagazine;
this.getPersonOnCover = getPersonOnCover;

Response.Write(month);
}

function getMagazine()
{
var objConn;
var objRS;
var strSQL;

var datePublished;

// open connection to the database

objConn = Server.CreateObject(&quot;ADODB.Connection&quot;);
objConn.ConnectionString = &quot;DSN=pb&quot;;
objConn.Open();

// create a recordset object

datePublished = this.month + this.year;

objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;);
strSQL = &quot;SELECT * FROM Magazine WHERE DatePublished = '&quot; + datePublished + &quot;'&quot;;
objRS.Open(strSQL, objConn);

this.datePublished = objRS(&quot;DatePublished&quot;);
this.yearPublished = objRS(&quot;YearPublished&quot;);
this.MonthPublished = objRS(&quot;MonthPublished&quot;);
this.Volume = objRS(&quot;Volume&quot;);
this.editionNumber = objRS(&quot;EditionNumber&quot;);
this.cover = objRS(&quot;Cover&quot;);
this.condition = objRS(&quot;Condition&quot;);
this.miscellanous = objRS(&quot;Miscellanous&quot;);
this.personOnCover = objRS(&quot;PersonOnCover&quot;);
this.needsReplaced = objRS(&quot;NeedsReplaced&quot;);

objRS.close();

objConn.close();
}

function getPersonOnCover()
{
return this.personOnCover;
}


// beginning of the script

var currentDate = new Date();
var currentYear = currentDate.getYear();
var currentMonth = currentDate.getMonth() + 1;

var strMonth;
var strCoverImg;

var magObj;

if (currentMonth <= 9)
strMonth = &quot;0&quot; + currentMonth;
else
strMonth = currentMonth;

magObj = new magazineObj(strMonth, currentYear);
magObj.getMagazine();

strCoverImg = &quot; l:\\Playboy\\Pbdb\\Covers\\Pb&quot; + strMonth + currentYear + &quot;.jpg&quot;;

Response.Write(strCoverImg);

Response.Write(magObj.getPersonOnCover());
%>
 
when you do this:

Code:
this.datePublished  = objRS(&quot;DatePublished&quot;);

this.datePublished is a reference to a ADODB.Field COM interface which of course becomes invalid after you do

Code:
objRS.close();

So you need to do this instead

Code:
this.datePublished  = objRS(&quot;DatePublished&quot;).value;

-pete

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top