I am calling a SQL Server database through my Web API which is then sending the data to my webpage only problem is when it does that some of the values are null and it errors.
How would I make it so when I pull the data using SQL that I make it check every column and row for nulls and change them to ''
without writing ISNULL(a.BuildingNumber, '')
or am I trying to attempt something that isn't possible.
Or is it possible to loop through the DataTable
that I make when C# gets the data from SQL Server, if so would something like a foreach loop work instead.
using(SqlCommand cmd = new SqlCommand(query, con))
{
cmd.CommandType = CommandType.Text;
var dtb = new DataTable();
var da = new SqlDataAdapter(cmd);
da.Fill(dtb);
return Json(dtb);
}
That is what I do after my query to return it.