使用SqlConnectionStringBuilder 方式來完成
SqlConnectionStringBuilder connBuilder = new SqlConnectionStringBuilder();
connBuilder.DataSource = ".";
connBuilder.InitialCatalog = "Northwind";
connBuilder.IntegratedSecurity = false;
connBuilder.UserID="xyz";
connBuilder.Password = "123";
string sql = "SELECT * FROM Employee";
SqlDataAdapter sda = new SqlDataAdapter(sql, connBuilder.ConnectionString);
DataSet ds = new DataSet();
sda.Fill(ds);
DetailsView1.DataSource = ds.Tables[0] ;
DetailsView1.DataBind();
沒有留言:
張貼留言