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

Server.CreateObject("ADODB.RecordSet") within JavaScript 1

Status
Not open for further replies.

raywesterhoff

Programmer
Oct 8, 2001
3
US
I am modifying code from another company and they use JavaScript EVERYWHERE. I need to hit the DB and build a <select> list. I get a &quot;Object Expected&quot; error when the code runs. A snip follows:

var payTypeSQL = &quot;SELECT PayTypeID, PayTypeName FROM VProfile WHERE &quot;;
payTypeSQL += &quot;Project_ID = '1-3-5-1-0-1'&quot;;
var payTypeRS = Server.CreateObject(&quot;ADODB.RecordSet&quot;);
payTypeRS.Open (payTypeSQL, conn, 1, 1);
payTypeRS.MoveFirst();
while (!payTypeRS.EOF)

The errors points to the last line. The SELECT is OK. Remember the language used is JavaScript.

Lost for now.

Ray W.
 
You should check to make sure that the recordset is not EOF or RecordCount is not = 0, before using the MoveFirst() method.

i.e.
Code:
payTypeRS.MoveFirst();
while (!payTypeRS.EOF)
should be:
Code:
if (payTypeRS.RecordCount != 0)
{
 payTypeRS.MoveFirst();
 while (!payTypeRS.EOF)
 {
  ...
 }
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top