62,263
社区成员
发帖
与我相关
我的任务
分享
public void Insert(BodyInfo myBodyInfo)
{
StringBuilder sb = new StringBuilder();
sb.Append(" INSERT INTO [GPSS].[dbo].[QUE_BODY]([QID],[BCODE],[BNAME],[BCATEGORY],[BTYPE],[BRULE1],[CREATEBY],[CREATEDATE],[UPDATEBY],[UPDATEDATE])\n");
sb.Append(" VALUES(@qid,@bcode,@bname,@bcategory,@btype,@brule1,@createby,@createdate,@updateby,@updatedate\n");
SqlParameter[] param = new SqlParameter[] {
new SqlParameter("@qid", SqlDbType.NVarChar,8),
new SqlParameter("@bcode",SqlDbType.NVarChar,2),
new SqlParameter("@bname",SqlDbType.NVarChar,255),
new SqlParameter("@bcategory",SqlDbType.NVarChar,1),
new SqlParameter("@btype",SqlDbType.NVarChar,1),
new SqlParameter("@brule1",SqlDbType.NVarChar,20),
new SqlParameter("@createby",SqlDbType.NVarChar,10),
new SqlParameter("@createdate",SqlDbType.DateTime),
new SqlParameter("@updateby",SqlDbType.NVarChar,10),
new SqlParameter("@updatedate",SqlDbType.DateTime),
};
param[0].Value = myBodyInfo.QID == null ? DBNull.Value : (object)myBodyInfo.QID;
param[1].Value = myBodyInfo.BCode == null ? DBNull.Value : (object)myBodyInfo.BCode;
param[2].Value = myBodyInfo.BName == null ? DBNull.Value : (object)myBodyInfo.BName;
param[3].Value = myBodyInfo.BCategory == null ? DBNull.Value : (object)myBodyInfo.BCategory;
param[4].Value = myBodyInfo.BType == null ? DBNull.Value : (object)myBodyInfo.BType;
param[5].Value = myBodyInfo.BRule1 == null ? DBNull.Value : (object)myBodyInfo.BRule1;
param[6].Value = myBodyInfo.CreateBy == null ? DBNull.Value : (object)myBodyInfo.CreateBy;
param[7].Value = myBodyInfo.CreateDate == null ? DBNull.Value : (object)myBodyInfo.CreateDate;
param[8].Value = myBodyInfo.UpdateBy == null ? DBNull.Value : (object)myBodyInfo.UpdateBy;
param[9].Value = myBodyInfo.UpdateDate == null ? DBNull.Value : (object)myBodyInfo.UpdateDate;
string strSQL = sb.ToString();
int i = SQLHelper.ExecuteNonQuery(strSQL, param);
}
固定了參數的我會寫,可是那麼多參數怎麼寫啊?