欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP.NET連接SQL數(shù)據(jù)庫的簡單實例代碼

 更新時間:2013年07月25日 10:39:28   作者:  
這篇文章介紹了ASP.NET連接SQL數(shù)據(jù)庫的簡單實例代碼,有需要的朋友可以參考一下

復制代碼 代碼如下:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HTMLControls;
using System.Data.SqlClient;

namespace Example01
{
///
/// WebForm1 的摘要說明。
///
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// 在此處放置用戶代碼以初始化頁面
Response.Write("第一個連接數(shù)據(jù)庫的實例");
SqlConnection myConnection = new SqlConnection("server=localhost;uid=sa;pwd=sa");
try
{
myConnection.Open();//打開數(shù)據(jù)庫鏈接
Response.Write("鏈接成功!");
}
catch
{
Response.Write("鏈接失?。?);
}
}

#region Web 窗體設計器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調用是 ASP.NET Web 窗體設計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

///
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
///
private void InitializeComponent()
{
this.Load = new System.EventHandler(this.Page_Load);
}
#endregion
}
}

相關文章

最新評論