ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

±NSQL¬d¸ß¥X¨Óªºµ²ªGÅã¥Ü¦b¬Yºô­¶¤W?

±NSQL¬d¸ß¥X¨Óªºµ²ªGÅã¥Ü¦b¬Yºô­¶¤W?

½Ð±Ð¥H¤Uµ{¦¡½X(ASP)¸Ó¦p¦ó­×§ï¤~·|°õ¦æ¦¨¥\¡A¦]¬°³£¹J¤W¤@¨Ç°õ¦æ¿ù»~¡A§Ú¬O·Q±NSQL¬d¸ß¥X¨Óªºµ²ªGÅã¥Ü¦b¬Yºô­¶¤W¡AÁÂÁ¡I
-----------------------------------------------------------------------------------------------------------------------------------------------------
//====== Step 1¡G«Ø¥ß¸ê®Æ®w³sµ²¡AµM«á¶}±Ò¸ê®Æ®w
conn = Server.CreateObject("ADODB.Connection");
conn.ConnectionString = "Driver={SQL Server};Server=XXXX;UID=XX;PWD=XXXX;Database=XXXXXXXX;"
conn.Open();

//====== Step 2¡G°õ¦æSQL«ü¥O¡A¨Ã±N¬d¸ßµ²ªGÀx¦s©ó Recordset ¤¤
sql = "SELECT * from test";        //±q¸ê®Æªí testTable ¨ú¥X©Ò¦³¸ê®Æ
rs = conn.Execute(sql);
%>

<table border=1 align=center>
<tr bgcolor="cyan">
<%
//====== Step 3¡G³z¹L RecordSet ¶°¦X¨ú±oÄæ¦ìªº¤º®e
//¦L¥XÄæ¦ì¦WºÙ
for (i=0; i<rs.Fields.Count; i++)
        Response.write("<th>"+rs(i).Name+"</th>\n");
%>
</tr>
<%
//¦L¥X¨C¤@µ§¸ê®Æ
while (!rs.EOF) {
        Response.write("<tr>\n");
        for (i=0; i<rs.Fields.Count; i++)
                Response.write("<td>"+rs(i)+"&nbsp;</td>\n");
        rs.MoveNext();
}
%>
</table>

<%
//====== Step 4¡GÃö³¬ RecordSet ¤Î¸ê®Æ®w³sµ²
rs.Close();
conn.Close();
%>

<hr>
----------------------------------------------------------------------------------------------------------------------------------
¿­·

        ÀR«ä¦Û¦b : µêªÅ¦³ºÉ¡D§ÚÄ@µL½a¡AµoÄ@®e©ö¦æÄ@Ãø¡C
ªð¦^¦Cªí ¤W¤@¥DÃD