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("ADODB.Connection"
;
objConn.ConnectionString = "DSN=pb";
objConn.Open();
// create a recordset object
datePublished = this.month + this.year;
objRS = Server.CreateObject("ADODB.Recordset"
;
strSQL = "SELECT * FROM Magazine WHERE DatePublished = '" + datePublished + "'";
objRS.Open(strSQL, objConn);
this.datePublished = objRS("DatePublished"
;
this.yearPublished = objRS("YearPublished"
;
this.MonthPublished = objRS("MonthPublished"
;
this.Volume = objRS("Volume"
;
this.editionNumber = objRS("EditionNumber"
;
this.cover = objRS("Cover"
;
this.condition = objRS("Condition"
;
this.miscellanous = objRS("Miscellanous"
;
this.personOnCover = objRS("PersonOnCover"
;
this.needsReplaced = objRS("NeedsReplaced"
;
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 = "0" + currentMonth;
else
strMonth = currentMonth;
magObj = new magazineObj(strMonth, currentYear);
magObj.getMagazine();
strCoverImg = " l:\\Playboy\\Pbdb\\Covers\\Pb" + strMonth + currentYear + ".jpg";
Response.Write(strCoverImg);
Response.Write(magObj.getPersonOnCover());
%>
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("ADODB.Connection"

objConn.ConnectionString = "DSN=pb";
objConn.Open();
// create a recordset object
datePublished = this.month + this.year;
objRS = Server.CreateObject("ADODB.Recordset"

strSQL = "SELECT * FROM Magazine WHERE DatePublished = '" + datePublished + "'";
objRS.Open(strSQL, objConn);
this.datePublished = objRS("DatePublished"

this.yearPublished = objRS("YearPublished"

this.MonthPublished = objRS("MonthPublished"

this.Volume = objRS("Volume"

this.editionNumber = objRS("EditionNumber"

this.cover = objRS("Cover"

this.condition = objRS("Condition"

this.miscellanous = objRS("Miscellanous"

this.personOnCover = objRS("PersonOnCover"

this.needsReplaced = objRS("NeedsReplaced"

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 = "0" + currentMonth;
else
strMonth = currentMonth;
magObj = new magazineObj(strMonth, currentYear);
magObj.getMagazine();
strCoverImg = " l:\\Playboy\\Pbdb\\Covers\\Pb" + strMonth + currentYear + ".jpg";
Response.Write(strCoverImg);
Response.Write(magObj.getPersonOnCover());
%>