I connect to an SQL database using ASP. I can see the records. I have a small (very basic) function written in Javascript. When I use the MoveNext in the function, it works fine. However, when I use it inside of a loop, the MoveNext does not work. Is this a known problem? Please help.
This is where I connect to the database from ASP:
Expand|Select|Wrap|Line Numbers
- <%
- Dim DeptID
- Dim DeptID_numRows
- Set DeptID = Server.CreateObject("ADODB.Recordset")
- DeptID.ActiveConnection = MM_A_CRS_STRING
- DeptID.Source = "SELECT * FROM dbo.mstrPersonnel ORDER BY ID ASC"
- DeptID.CursorType = 0
- DeptID.CursorLocation = 2
- DeptID.LockType = 2
- DeptID.Open()
- DeptID_numRows = 0
- %>
The MoveNext command NEVER works inside of the LOOP but works anywhere else in the function.
Expand|Select|Wrap|Line Numbers
- <script type="text/javascript">
- function Owner() {
- <% DeptID.MoveFirst() %>;
- var y = "<%= Session("TotalRec") %>"; // is total number of record in recordset
- alert ("y from session = " + y);
- <% DeptID.MoveFirst() %>;
- alert(" <%=(DeptID.Fields.Item("DeptID").Value)%>" + " from pull dowm = " + document.frmCRSContract.Department_ID.value + " Current Record ID = " + "<%=(DeptID.Fields.Item("ID").Value)%>")
- <%DeptID.MoveNext()%>;
- alert(" <%=(DeptID.Fields.Item("DeptID").Value)%>" + " from pull dowm = " + document.frmCRSContract.Department_ID.value + " Current Record ID = " + "<%=(DeptID.Fields.Item("ID").Value)%>")
- var x = 1;
- while (x <= y)
- {
- <%DeptID.MoveNext()%>;
- alert(" in loop Current deptID = " + "<%=(DeptID.Fields.Item("DeptID").Value)%>" + " from pull dowm = " + document.frmCRSContract.Department_ID.value + " Current Record ID = " + "<%=(DeptID.Fields.Item("ID").Value)%>");
- x = x + 1
- } // End of LOOP
- alert(" deptID = " + "<%=(DeptID.Fields.Item("DeptID").Value)%>");
- } // end Function
- </script>