Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在int ID为null的情况下筛选数据表_C#_Mysql - Fatal编程技术网

C# 如何在int ID为null的情况下筛选数据表

C# 如何在int ID为null的情况下筛选数据表,c#,mysql,C#,Mysql,我有gridview和 GridViewName.DataSource = table; 表值: string myConnection = ConfigurationManager.ConnectionStrings["vizitka"].ToString(); string Query_sel = MySqlString; MySqlConnection conDataBase = new MySqlConnection(myConnection); MySqlCommand cmdDat

我有gridview和

GridViewName.DataSource = table;
表值:

string myConnection = ConfigurationManager.ConnectionStrings["vizitka"].ToString();
string Query_sel = MySqlString;
MySqlConnection conDataBase = new MySqlConnection(myConnection);
MySqlCommand cmdDataBase_sel = new MySqlCommand(Query_sel, conDataBase);
try
{
    MySqlDataAdapter sda = new MySqlDataAdapter();
    sda.SelectCommand = cmdDataBase_sel;
    DataTable dbdataset = new DataTable();
    sda.Fill(dbdataset);
    BindingSource bSource = new BindingSource();
    bSource.DataSource = dbdataset;
    TableName.DataSource = bSource;
    sda.Update(dbdataset);
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}
我得到的价值观是:

然后,我将向表中添加新行:

DataRow newRow = table.NewRow();
table.Rows.Add(newRow);
以及使用空单元格获取值(ID也是空的,这对我有好处):

然后:

一切都很好,但若我想从表中删除这个新创建的行,那个么我就不能。我正在尝试再次筛选和绑定GridViewName

DataView view = new DataView(table);
view.RowFilter = "CONVERT(id, System.String) = null or CONVERT(id, System.String) = ''";
Console.WriteLine(view);

但我的桌子空了。为什么?

我假设ID是数字。您不希望=null,希望为null,这就是在DataView(以及SQL)中检查null的方式


我尝试了很多变种。。。我记得,我已经试过“是空的”,但可能不是。。。现在它开始工作了,谢谢。请注意,除了使用
RowFilter
DataView view = new DataView(table);
view.RowFilter = "CONVERT(id, System.String) = null or CONVERT(id, System.String) = ''";
Console.WriteLine(view);
view.RowFilter = "ID IS NULL";