我查詢數據庫以檢索所有列。我可能會有很多行。我試圖輸出查詢結果到一個HTML表格。這是我到目前爲止:在html中輸出查詢結果
protected void Page_Load(Object sender, EventArgs E)
{
message.Text = "Welcome to your profile: " + CUser.LoginID;
System.Data.SqlClient.SqlConnection con;
con = new System.Data.SqlClient.SqlConnection();
con.ConnectionString = "Data Source=.\\SQLEXPRESS; AttachDbFilename=C:\\Users\\jjj\\Documents\\Visual Studio 2010\\Projects\\App_Data\\data.mdf; Integrated Security = true; Connect Timeout = 30; User Instance = True";
string id = CUser.LoginID;
try
{
con.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM tbl WHERE loginID = 'hussein' ", con);
SqlDataReader reader =cmd.ExecuteReader();
if (reader.HasRows) {
//reader.Read();
while (reader.Read())
{
}
}
}
catch { }
finally
{
con.Close();
}
}
我怎麼能存儲多行並輸出他們使用HTML一旦我打開一個頁面?即時通訊使用C#