通过按下按钮,我尝试使用来自 SQL Server 的数据库和其他表来更新 ASP.net 站点上的 GridView,但它没有改变,没有“捕获”。
GridView 不会出现。
{
SqlConnection sqlConnection1;
sqlConnection1 = new SqlConnection(@"Data Source=ELAD_HA\SQLEXPRESS;Initial Catalog=Users;Integrated Security=True");
SqlCommand sqlCommand1;
sqlCommand1 = new SqlCommand("SELECT * FROM TBUsers ORDER BY Name", sqlConnection1);
try
{
DataSet ds = new DataSet();
SqlDataAdapter adptr = new SqlDataAdapter(sqlCommand1);
SqlCommandBuilder comb = new SqlCommandBuilder(adptr);
adptr.Fill(ds,"T1");
GridView2.DataSource = ds.Tables["T1"];
//GridView2.DataSource = ds;
//GridView2.DataMember = "T1";
}
catch (SqlException ex)
{
SuccessLabel1.Text = ex.Message.ToString();
}
}
代码有什么问题吗?
PS
我可以将数据源更改为我从菜单中选择数据源的 GridView 吗?(来自“分割”屏幕)。
感谢各位的帮助。
呼啦一阵风
相关分类