<%...
VaR connstr = "" provider = sqloledb; Data Source = localhost; initial catalog = jiaojingdb; user id = sa; Password = 123456 ;"
VaR conn = server. Createobject ("ADODB. Connection"); // The purpose of defining Conn is to improve efficiency and close () later, but the physical connection still exists, resulting in high efficiency.
Conn. Open (connstr );
// ** Call the stored procedure through the connection object **
VaR rs = conn. Execute ("getuserlist",) 'the last parameter is the same as commandtype
// Entity:
While (! Rs. EOF ){
Response. Write ("<br>" + RS ("title ");
Rs. movenext ();
}
// Remember to close ()
Rs. Close ();
Conn. Close ();
// If the deletion is performed: conn. Execute (SQL)
/** Call the stored procedure through the recordset object **
// Var myrst = server. Createobject ("ADODB. recordset ")
// Myrst. Open (getuserlist ", myconstr, 0, 1, 4)
// 'Myconstr is the database connection string. The last parameter has the same meaning as commandtype. The second to the last parameter indicates reading, and the third parameter indicates adding, deleting, and modifying.
*/
/** // * Common attributes and methods in the recordset component include:
Rs. Fields. Count: number of fields in the recordset object.
RS (I). Name: name of the I-th field, where I is 0 to Rs. Fields. Count-1
RS (I): The data of field I, where I is 0 to Rs. Fields. Count-1
RS ("field name"): Specifies the data of a field.
Rs. Record. Count: Total number of data records in the cursor.
Rs. EOF: indicates whether the last record is used.
Rs. movefirst: point to the first record.
Rs. movelast: point to the last record.
Rs. moveprev: point to the previous record.
Rs. movenext: point to the next record.
Rs. getrows: puts data into the array.
Rs. properties. Count: the number of attributes of the resultset or connection of ADO.
Rs. properties (item). Name: name of the resultset or connection of ADO.
Rs. properties: The resultset or connection value of ADO.
Rs. Close (): Close the connection.
Close Database
Conn. Close ()*/
%>
There are better solutions for small data sets in vbs:
Let's make Rs. getrows clearer.
Rs. getrows (n): n indicates the number of records retrieved.
Rs. getrows (1): 1 indicates that only one record is returned.
Rs. getrows (-1):-1 indicates the default value. All records are returned.
Use the getrows method to generate a two-dimensional array
If not Rs. EOF then
Dim rsarr
Rsarr = Rs. getrows (-1)
For I = 0 to ubound (rsarr, 2) 'traverse record rows
For J = 0 to ubound (rsarr, 1) 'traverse record Columns
Response. Write rsarr (J, I) 'to obtain the record data in row I + 1 and column J + 1.
Next
Next
End if
Are you clear about the two codes?
Weblogarr = weblog. getrows (log_num) 'to get all data
Ubound (weblogarr, 2) 'to get all rows
Weblogarr (1, pagecount) 'returns the 2nd columns displayed on each page, that is, log_cateid.
Unfortunately, there are no two-dimensional and multi-dimensional arrays in Javascript. I solve this problem through the following methods:
<%...
Response. Write ("<SCRIPT arr = new array ();");
VaR arri = 0;
While (! Rs. EOF ){
Response. Write ("arr [" + arri + "] = '" + RS (2) + "';");
Rs. movenext ();
Arri ++;
Response. Write ("</SCRIPT> ");
%>