0

I have a SQL stored procedure which returns below data:

Id  data
1   {test12,sahjfh}
2   {test3,asfdssd}
3   null
4   null
5   {test454,aslkdfs}

i am trying to remove all the null value data , by using below code however its not working

public void TestMethod(){
// get the data from DB in list
            var InputList = new List<object>();
            using (SqlConnection con = new SqlConnection(conString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {

                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = "dbo.ReadAll_Input";

                    con.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            InputList.Add(dr["data"]);
                        }
                    }
                }
            }
            InputList.RemoveAll(data => data == null);


}

Any hints on this?

Thanks!

TechnoSavvy
  • 107
  • 4
  • 18

0 Answers0