Marius Vasile

Marius Vasile

  • 603
  • 1.7k
  • 124.7k

Handling empty string or null values

Aug 18 2023 8:17 AM

I am having the following issue. In a table I have a string which by default is empty, type nvarchar(2). When I run select query, it does not display any data despite I have filled the table if in WHERE condition I put that column. See below the sql query

DataList1.DataSource = GetData("SELECT * FROM (SELECT TOP 1 * FROM tblTestDetail) td JOIN tblIntrebare ti ON td.IdIntrebare = ti.IdIntrebare WHERE (td.Corect IS NULL OR td.Corect='')");
if (DataList1 != null)
{
    DataList1.DataBind();
}
else
{
    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('No Data')", true);
}

If I use the same query but WHERE condition td.Corect='NU' I get the data displayed. What am I doing wrong?


Answers (1)