有没有办法为Insert查询使用参数?我尝试时收到以下错误。
/// <summary>
/// Set active survey
/// </summary>
public int SetSurveyActive(int brandId, int surveyId)
{
Sql sql = new Sql()
.Append("INSERT INTO CF.ActiveSurvey(BrandId, SurveyId")
.Append("VALUES(@0,@1)",brandId,surveyId);
var result = database.Execute(sql);
return Convert.ToInt32(result);
}
答案 0 :(得分:5)
您缺少一个括号:
.Append("INSERT INTO CF.ActiveSurvey(BrandId, SurveyId")
应该是
.Append("INSERT INTO CF.ActiveSurvey(BrandId, SurveyId)")