Search code examples
c#dataset

C# to check in DataSet row a key exists or not


in the below code, I need to check whether the DBMSType exists or not.

string filename = @"D:\service\configfile.json";

DataSet data = JsonConvert.DeserializeObject<DataSet>(File.ReadAllText(filename));

if (data.Tables[0].Rows.Count > 0)
{
   var n = data.Tables[0].Rows[0]["DBMSType"].ToString();

}

Solution

  • this is the solution got working for me

    so just try the below validation it is working fine

    data.Tables[0].Columns.Contains("DBMSType")