hello friend
try
{
if (cn.State == ConnectionState.Closed)
{
cn.Open();
}
for (int i = 0; i < dt1.Rows.Count - 1; i++)
{
string check = "select name,days,hdays,months,years * from inventory";
ad2.fill = ad2();
string _whr = "select * from inventory where name= 'priya' + dt1.Rows[i][name].ToString()+ = "'," Convert.ToInt32(dt1.Rows[i][days] + hdays = '1'+ Convert.ToInt32(dt1.Rows[i][hdays] + months = '1'+ Convert.ToInt32(dt1.Rows[i][months] + years = '1'+ Convert.ToInt32(dt1.Rows[i][years]+ ")"; how to write where query
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();
}
}
}
Aloktiwari588-19868, if this helps please login to Mark As Answer. | Alert Moderator