


















数据库连接字符串:
<connectionStrings>
<add name="AdventureWorksDWConnectionString" connectionString="Data Source=QQ123\SQL2005;Initial Catalog=AdventureWorksDW;Persist Security Info=True;User ID=sa;Password=7894561230."
providerName="System.Data.SqlClient" />
</connectionStrings>
在C#语句的连接方式语句:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string con = ConfigurationManager.ConnectionStrings["AdventureWorksDWConnectionString"].ConnectionString;
Label2.Text = con;

SqlConnection conn = new SqlConnection(con);

SqlDataAdapter asd = new SqlDataAdapter();
asd.SelectCommand = new SqlCommand("select * from DatabaseLog", conn);
DataSet ds = new DataSet();
asd.Fill(ds, "emp");


this.GridView1.DataSource = ds.Tables["emp"];
this.GridView1.DataBind();

}
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。