我有一个叫做DueInTable带字段的表RepairNumber.
如何编写一个仅返回此字段不为空的gridDataView中的记录的SQL语句?
这是我尝试OnLoad用于表格的事件:
label1.BackColor = Color.Transparent;
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
string data = "Select * from DueInTable WHERE RepairNumber = !NULL";
DataTable dt = new DataTable();
DataSet ds = new DataSet();
OleDbDataAdapter adapter = new OleDbDataAdapter(new OleDbCommand(data, connection));
adapter.Fill(ds);
DataView DV = new DataView();
DV.Table = ds.Tables[0];
Repair_dtGrdVw.DataSource = DV;
Run Code Online (Sandbox Code Playgroud)
WHERE RepairNumber = !NULL实际上在SQL 中意味着repairNumber不是'undefined'.由于"未定义的东西"(或者你无法确定其值)永远不会是"未定义的东西",因此与之相比=总会失败.
这就是为什么有一个is (not) null运营商:
WHERE RepairNumber is not null
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
39 次 |
| 最近记录: |