for (int i = 0; i < dt1.Rows.Count - 1; i++)
{
string check = "select name,days,months,years,hdays from inventory";// null show here
DataTable dt2 = new DataTable();
ad.Fill(dt2);
string where = "Select name,days,months,years,hdays from inventory where name = name and days = 1 and months = 1 and years = 1 and hdays = 1";
if (dt1.Rows.Count > 0)
{ }
else
{
string insert = "insert into inventory(name,days,hdays,months,years)values('" + dt1.Rows[i]["name"].ToString() + "'," + Convert.ToInt32(dt1.Rows[i]["days"]) + "," + Convert.ToInt32(dt1.Rows[i]["hdays"]) + "," + Convert.ToInt32(dt1.Rows[i]["months"]) + "," + Convert.ToInt32(dt1.Rows[i]["years"]) + ")";
SqlCommand ad2 = new SqlCommand(insert, cn);
ad2.ExecuteNonQuery();
}
}
}
Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator