using System.Data.SqlClient;
SqlConnection con = new SqlConnection("Data Source=(local);Database=Da
taBaseName;Uid=sa;Pwd=1234
56");
SqlCommand com = new SqlCommand("select * from House", con);
con.Open();
SqlDataReader dr = com.ExecuteReader();
DataTable schemaTable = dr.GetSchemaTable();
Response.Write("<table border=1>");
foreach (DataRow myField in schemaTable.Rows)
{
Response.Write("<tr>");
//For each property of the field...
foreach (DataColumn myProperty in schemaTable.Columns)
{
//Display the field name and value.
Response.Write("<td>" + myProperty.ColumnName + " = " + myField[myProperty].ToStri
ng() + "</td>");
}
Response.Write("</tr>");
}
Response.Write("</table>")
;
dr.Close();
con.Close();
转载自
http://hi.baidu.com/womenj
iushijingcai/blog/item/2bc
36922cdf175a34723e8fc.html
暂时没有评论