ADO GetRows - Properties เหตุผลที่เน้นในส่วนของ GetRows เพราะผมเห็นว่ามันจะมีประโยชน์มาก ๆ ในการนำไปใช้งาน เพราะในภาษา ASP ไม่สามารถที่จะทำการใช้งาน RecordSet Pointer หลังจากที่ทำการปิด RecordSet แล้ว และในการเขียนโปรแกรมที่มีการเปิด RecordSet หลาย ๆ แล้ว ในบางครั้งการเขียนโปรแกรมในรูปแบบของ Transaction จะไม่สามารถเขียนได้ จำเป็นจะต้องทำการคงไว้เพียง RecordSet เดียวเท่านั้น หรือไม่ก็ใช้การเก็บค่าในรูปแบบของ Array หรือจะลองใช้คำสั่ง GetRows จะเป็นการเก็บข้อมูลที่ได้จาก RecordSet ลงในรูปแบบของ Array  
 
Syntax 
 
arrGetRows = ObjRec.GetRows() 
 
arrGetRows(Fields,Rows)  
 
 
 
Sample 
 
<% Option Explicit %>
<html>
<head>
<title>ThaiCreate.Com ASP & Microsoft Access Tutorial</title>
</head>
<body>
<%
Dim Conn,strSQL,objRec,arrData,i
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("mydatabase.mdb"),"" , ""
strSQL = "SELECT * FROM customer "
Set objRec = Conn.Execute(strSQL)
arrData = objRec.GetRows()
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing	
'*** arrData(Field,Rows) ***'
%>
<table width="600" border="1">
  <tr>
    <th width="91"> <div align="center">CustomerID </div></th>
    <th width="98"> <div align="center">Name </div></th>
    <th width="198"> <div align="center">Email </div></th>
    <th width="97"> <div align="center">CountryCode </div></th>
    <th width="59"> <div align="center">Budget </div></th>
    <th width="71"> <div align="center">Used </div></th>
  </tr>
<%
	For i = 0 To Ubound(arrData,2)
%>
	  <tr>
		<td><div align="center"><%=arrData(0,i)%></div></td>
		<td><%=arrData(1,i)%></td>
		<td><%=arrData(2,i)%></td>
		<td><div align="center"><%=arrData(3,i)%></div></td>
		<td align="right"><%=arrData(4,i)%></td>
		<td align="right"><%=arrData(5,i)%></td>
	  </tr>
<%
	Next
%>
</table>
<%
	
%>
</body>
</html>       
Screenshot 
 
               
  
              			
			  
								  
			  
  
                          
  |