Dataset操作データベースデータ読み出しリスト表示
1429 ワード
Default.aspx.csファイル:
html += "";
html += "";
html += "";
foreach(DataRow dr in drc)
{
html += "";
html += "";
html += "";
html += "";
html += "";
}
html += "idnamepwd" + dr["id"].ToString() + "" + dr["name"].ToString() + "" + dr["pwd"].ToString() + "";
this.table_html.InnerHtml = html;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Data.Common;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("server=hannibal-pc\\hansql;uid=sa;pwd=xiaoaiai;database=test;min pool size=10;max pool size=512");
String sql=" select * from person ";
SqlDataAdapter cmd = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
cmd.Fill(ds, "person");
DataTable dt=ds.Tables[0];
DataRowCollection drc=dt.Rows;
String html="";
html += "
";html += "";
html += "";
html += "";
foreach(DataRow dr in drc)
{
html += "";
html += "";
html += "";
html += "";
html += "";
}
html += "idnamepwd" + dr["id"].ToString() + "" + dr["name"].ToString() + "" + dr["pwd"].ToString() + "";
this.table_html.InnerHtml = html;
}
}