public static int SetSelectedItem(string[] sValues)
{
int nRow = 0;
try
{
foreach (string str in sValues)
{
SqlCommand cmdUpdate = new SqlCommand("UPDATE [dbo].[tblProductsManager] SET IsActive = 1 WHERE Id= '" + str + "' ", con);
if (con.State == ConnectionState.Closed)
con.Open();
nRow = cmdUpdate.ExecuteNonQuery();
}
}
catch { }
finally
{
if (con.State == ConnectionState.Open)
con.Close();
}
return nRow;
}
in the above code, "cmdUpdate.ExecuteNonQuery();" call for every value of "sValues".
if have any idea, plz help me.
Anonymous User
19-Nov-2012It resolve my problem
Thanks
Anonymous User
19-Nov-2012You can use StringBuilder concept here, replace your code with following code:
Please mark as answer if this code will resolve your problem.