Truy xuất dữ liệu bằng DataAdapter, đọc dữ liệu vào DataSet
{ string connectionString = "Data Source=.;
Initial Catalog=HSDB;
Integrated Security=SSPI;";
SqlConnection conn = new SqlConnection(connectionString);
DataSet ds = new DataSet();
Try
{
if (conn.State == ConnectionState.Closed)
{ conn.Open(); }
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select MaLop, TenLop from Lop";
cmd.Connection = conn;
using(SqlDataAdapter adapter = new SqlDataAdapter(cmd))
{ adapter.Fill(ds, "Lop"); }
this.ddlLop.DataSource = ds;
this.ddlLop.DataMember = "Lop";
this.ddlLop.DataTextField = "TenLop";
this.ddlLop.DataValueField = "MaLop";
this.ddlLop.DataBind();
return true;
}
catch { return false; }
finally { conn.Close(); }
}
- Tìm hiểu quy ước đặt tên thiết bị lưu trữ trong Linux
- Tìm hiểu cấu trúc i-node và cách đọc thông tin tệp tin trong Linux
- Xu hướng mới trong phân tích và thiết kế hệ thống thông tin
- MuZero – Thuật toán Trí tuệ nhân tạo có khả năng tự học mạnh mẽ
- Chủ đề OSCP (Port Redirection and SSH Tunneling) (tiếp theo)