我已按照此处发布的教程编写代码 http://csharp.net-informations.com/datagridview/csharp-datagridview-filter.htm
但是我一直收到错误"找不到表0",我尝试了几件事,但没有一件事有效
我已经在我的表单加载中发布了代码,并且按钮启动了该过程
string connectionString = "server=localhost;user id=root;database=epas=";
string sql = "SELECT * FROM pricing sterling";
SqlConnection con = new SqlConnection(connectionString);
SqlDataAdapter dataadapter = new SqlDataAdapter(sql, con);
con.Open();
dataadapter.Fill(ds, "pricing table");
con.Close();
dataGridView1.DataSource = ds.Tables[0];
按钮
DataView dv;
dv = new DataView(ds.Tables[0], "ID = '21' ", "type Desc", DataViewRowState.CurrentRows);
dataGridView1.DataSource = dv;
答案 0 :(得分:1)
从
中的数据表名称中删除空格dataadapter.Fill(ds,“pricingtable”);