use Dictionary for this put column name as key and the corresponding value-
void Runcommand(string tableName,Dictionary<string,object>updatevalues, string wherecaluse)
{
SqlCommand cmd=new SqlCommand(conn);
cmd.CommandText="update "+tableName +" Set ";
bool isAdded=false;
foreach(string key in updatevalues.keys)
{
if(isAdded)
{
cmd.CommandText+=", ";
}
isAdded=true;
cmd.CommandText+=string.Format("{0}=@{0}",
cmd.Parameters.Add(new SqlParameter(key,updatevalues[key]);
}
cmd.CommandText+=" where "+whereclause;
cmd.ExcuteNonQuery();
}
hope this will work for you.