我正在尝试将记录插入到我的SQL数据库中,该数据库的列值如下所示:
6" PVC vent 140' S, 4' W of NW crnr of bldg
我尝试在此值的前端和末尾放置单引号,并尝试在此值的前端和末尾加上双引号。两者都会导致“语法不正确”错误。两者都以 140'结束值,并将 S 作为另一个值启动。我真的需要解决这个问题,因为我很遗憾地在数据库中看到了这样的多个值。
以下是我的完整INSERT
声明,上面的值是 SMPL_PT_DESC 列:
INSERT INTO CC_MSD_LIMS_STAGING (SMN, FACILITY_ID,SCHEDULE_DATE, IND_NAME, ADDRESS_LINE_1, ADDRESS_LINE_2, CITY, STATE, ZIP, SMPL_PT_DESC, SMPL_PT_NUM, SPLIT, TRUCK_ID, PROJECT_TYPE, SAMPLER, IND_ID, BOTTLE_TYPE, PRESERVATIVE, SAMPLE_TYPE, POLLUTANT, UNITS, SIU_IND, SURCHARGE_IND, SPECIAL_INSTRUCTIONS, AUTOSAMPLER_READY, SHIFT_L, SHIFT_START_TIME, PRIMARY_CONTACT_FIRSTNAME, PRIMARY_CONTACT_LASTNAME, PRIMARY_CONTACT_PHONE, ALTERNATE_CONTACT_FIRSTNAME, ALTERNATE_CONTACT_LASTNAME, ALTERNATE_CONTACT_PHONE, MONITORING_ID)
VALUES ('1793175', '1037247400', '11/13/2017 12:00:00 AM', 'STONETRENDS LLC', '18092 Chesterfield Airport', '', 'Chesterfield', 'MO', '63005', '6" PVC vent 140' S, 4' W of NW crnr of bldg', '001', 'N', '493', 'IM', 'M', '2464', 'P0', 'None', 'T04', 'T208000', 'mg/L', '', 'Y', '', 'Y', '1', '0700AM', 'Patrick ', 'Martin', '6365371607', 'Stefan ', 'Landgraf', '6365371607', '-1')
答案 0 :(得分:0)
您应该为.net编译器和\"
(double')代替""
或@
(如果使用"
)而不是''
{1}}
对于sql server。
'
或string sql = "INSERT INTO CC_MSD_LIMS_STAGING (SMN, FACILITY_ID,SCHEDULE_DATE, IND_NAME, ADDRESS_LINE_1, ADDRESS_LINE_2, CITY, STATE, ZIP, SMPL_PT_DESC, SMPL_PT_NUM, SPLIT, TRUCK_ID, PROJECT_TYPE, SAMPLER, IND_ID, BOTTLE_TYPE, PRESERVATIVE, SAMPLE_TYPE, POLLUTANT, UNITS, SIU_IND, SURCHARGE_IND, SPECIAL_INSTRUCTIONS, AUTOSAMPLER_READY, SHIFT_L, SHIFT_START_TIME, PRIMARY_CONTACT_FIRSTNAME, PRIMARY_CONTACT_LASTNAME, PRIMARY_CONTACT_PHONE, ALTERNATE_CONTACT_FIRSTNAME, ALTERNATE_CONTACT_LASTNAME, ALTERNATE_CONTACT_PHONE, MONITORING_ID) VALUES ('1793175', '1037247400', '11/13/2017 12:00:00 AM', 'STONETRENDS LLC', '18092 Chesterfield Airport', '', 'Chesterfield', 'MO', '63005', '6\" PVC vent 140'' S, 4'' W of NW crnr of bldg', '001', 'N', '493', 'IM', 'M', '2464', 'P0', 'None', 'T04', 'T208000', 'mg/L', '', 'Y', '', 'Y', '1', '0700AM', 'Patrick ', 'Martin', '6365371607', 'Stefan ', 'Landgraf', '6365371607', '-1')";
@