c# update
我想根据我传入的参数是否为空执行我的update语句,但是我现在不知道如何去加逗号。好像加在哪都不对。哪位高手帮我修改一下我的语句,让他能够正确的执行。
StringBuilder eidt = new StringBuilder();
eidt.Append("update ZT_User set");
if (!string.IsNullOrEmpty(user.Url))
{
eidt.Append(" url ='");
eidt.Append(user.Url);
eidt.Append("'");
}
if (!string.IsNullOrEmpty(user.Cimg))
{
eidt.Append(" cimg ='");
eidt.Append(user.Cimg);
eidt.Append("'");
}
if (!string.IsNullOrEmpty(user.Logo))
{
eidt.Append(" logo ='");
eidt.Append(user.Logo);
eidt.Append("'");
}
eidt.Append(" where UserId = '");
eidt.Append(user.UserId);
eidt.Append("'");