제목 : 예제. SqlDataAdapter 클래스를 사용한 DataTable 채우기(C#)
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%
SqlConnection objCon;
SqlDataAdapter objDa;
DataSet objDs;
//DataRow objDr;
objCon = new SqlConnection();
objCon.ConnectionString = "server=localhost;database=Pubs;user id=sa;password=1234";
objDa = new SqlDataAdapter("Select Top 5 * From Authors", objCon);
objDs = new DataSet();
objDa.Fill(objDs, "Authors");
foreach(DataRow objDr in objDs.Tables["Authors"].Rows)
{
Response.Write(objDr["au_lname"] + "<br>");
}
%>