如何在存储库组合框中放置一个null,其中数据类型是日期时间? 或者我应该将日期时间转换为null? 我试着把这段代码给我错误
public void store()
{
GridView view = sender as GridView;
for (int i = 0; i < gridView1.RowCount; i++)
{
if (gridView1.GetDataRow(i)["signOut"] == DBNull.Value)
{
DateTime? px = null;
if (!repositoryItemComboBox10.Items.Contains(px))
{
repositoryItemComboBox10.Items.Add(px);
}
}
}
}
其他catch
method
public void SDB()
{
SqlDataAdapter adapter2 = new SqlDataAdapter(command.CommandText, myConnection);
try
{
ds2.Clear();
dt2.Clear();
command2.Connection = myConnection;
command2.CommandText = " ..."
adapter2.SelectCommand = command2;
adapter2.Fill(ds2);
adapter2.Fill(dt2);
gridControl1.DataSource = dt2;
myConnection.Open();
}
catch (Exception ex)
{
MessageBox.Show("error" + ex);
}
finally
{
myConnection.Close();
}
结论我想要的是获取过滤器,如果注销为空或空 image that i want
答案 0 :(得分:0)
错误是因为您无法将null直接指定给日期。您可以按如下方式创建可以为空的日期
DateTime? px = (DateTime?)null;