我有一个基于 EmpID 显示名称的命令:
using (SqlCommand SqlCommand = new SqlCommand("Select EmpID, Name from EmpTable where EmpID = @a", myDatabaseConnection))
{
SqlCommand.Parameters.AddWithValue("@a", textBox1.Text);
using (SqlDataReader sqlreader = SqlCommand.ExecuteReader())
{
if (sqlreader.Read())
{
Namelabel.Text = sqlreader.GetString(sqlreader.GetOrdinal("Name"));
}
}
}
如果名称数据是,我将如何处理null
?就像数据是null
Namelabel.Text = ""
.