<%@Import Namespace ="System.Data"%>
<%@Import Namespace="System.Data.SqlClient"%>
void Page_Load(Object sender, EventArgs e) {
try
{
string connString = "server=(local);uid=sa;pwd=;database=banhang";
SqlConnection con = new SqlConnection(connString);
con.Open();
string query = "select * from mathang";
SqlCommand command = new SqlCommand(query, con);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Response.Write(reader.GetString(0) + "-" + reader.GetString(1)+"
");
//Response.Write(reader["mahang"] + "-" + reader["tenhang"]);
//Response.Write(reader[0] + "-" + reader[1] + "
");
}
reader.Close();
con.Close();
}
catch (Exception err)
{
Label1.Text = "Error" + err.Message + "
";}
}
» Tin mới nhất:
» Các tin khác: