//创建insert语句 private List<string> GetInsertSqlFromListPA_SD(List<PA_SD> list) { List<string> sqlList = new List<string>(); string strSQL = @"Insert Into PA_SD(DNDH,pono,itemno,style,product,materdesc,prdsize,qty,subprddesc) Values({0},{1},{2},{3},{4},{5},{6},{7},{8}) "; foreach (PA_SD obj in list) { sqlList.Add(string.Format(strSQL, SqlParamFomat(obj.DNDH), SqlParamFomat(obj.pono), obj.itemno, SqlParamFomat(obj.style), SqlParamFomat(obj.product), SqlParamFomat(obj.materdesc), SqlParamFomat(obj.prdsize), obj.qty, SqlParamFomat(obj.subprddesc) )); } return sqlList; } private string SqlParamFomat(string str) { if (null != str) { string tmp = str.Replace("'", "''"); return "'" + tmp + "'"; } else { return "null"; } }