SqlDataAdapter.fill()返回3,但DataTable为空

时间:2018-06-24 22:59:30

标签: datatable fill sqldataadapter

我正在尝试对数据库执行选择查询,然后将结果显示到Webform上。我为此使用SqlDataAdapter和DataTable。问题是我的数据库有3行,而SqlDataAdapter.fill()返回3,但数据表仍然为空。

代码:

SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString);
conn.Open();
string all_user_get = "select * from regTable";
SqlCommand all_com = new SqlCommand(all_user_get, conn);
all_com.CommandTimeout = 30;

SqlDataAdapter sda = new SqlDataAdapter(all_com);

DataTable dt = new DataTable();

sda.Fill(dt);
userGrid.DataSource = dt;
userGrid.DataBind();

0 个答案:

没有答案
相关问题