1. Tao Ket noi voi database:
SqlConnection sqlconStudentData;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
sqlconStudentData = new SqlConnection(WebConfigurationManager.ConnectionStrings["StudentDataConnectionString"].ConnectionString);
sqlconStudentData.Open();
}
}
2. Thu xem ket noi co thanh cong khong:
protected void btnConnect_Click(object sender, EventArgs e)
{
Controls.Clear();
Response.Write("The database connection is successfully established.<br />");
Response.Write("<strong>ConnectionString Name: </strong>" + WebConfigurationManager.
ConnectionStrings["StudentDataConnectionString"].Name + "<br />");
Response.Write("<strong>Provider Name: </strong>" + WebConfigurationManager.
ConnectionStrings["StudentDataConnectionString"].ProviderName + "<br />");
Response.Write("<strong>Total ConnectionString: </strong>" + WebConfigurationManager.
ConnectionStrings.Count + "<br />");
}
Link download : https://www.mediafire.com/?kuu8x2giksco31a
Đăng ký:
Đăng Nhận xét (Atom)
0 nhận xét:
Đăng nhận xét