如果列中沒有值和根據此示例,某些特定字段沒有任何字符返回空白(僅「」),我如何能返回空值。如果列中沒有值,我該如何返回空值
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public DataTable GetEmployeeInformation(string USERID)
{
string constr = ConfigurationManager.ConnectionStrings["MyCon"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT * FROM VW_NTB_EIM_O365 WHERE [email protected]"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Parameters.AddWithValue("@USERID", USERID);
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
dt.TableName = "NTB_EIM_O365";
sda.Fill(dt);
if (dt == null)
{
return null;
}
return dt;
}
}
}
}
}
}
}