这是我第一次进入 MySQL 世界。但是,我收到了这个错误。
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' '9/30/2012 12:00:00 AM', '10/1/2012 12:00:00 AM', '9/30/2012 12:00:00 AM', '', ' at line 1
命令文本很长,所以我很抱歉。另外,是的,我知道 SQL 注入以及如何防止它;但是,此程序仅供内部使用,不承担此风险。
foreach (DataRow r in dt.Rows)
{
cmd = connection.CreateCommand();
cmd.CommandText = "INSERT INTO `" + TableName + "`";
cmd.CommandText += "(ControlNumber, Jur_ID, Jur_Status, Jur_Collected, 1Jur_Yr, 1Jur_Install, 1Jur_Amt, 1Jur_Paid, 1Jur_Due, 1Jur_DtDue, 1Jur_FinalDue, 1Jur_DtPaid, 1Jur_Thru, ";
cmd.CommandText += "2Jur_Yr, 2Jur_Install, 2Jur_Amt, 2Jur_Paid, 2Jur_Due, 2Jur_DtDue, 2Jur_FinalDue, 2Jur_DtPaid, 2Jur_Thru, 3Jur_Yr, 3Jur_Install, 3Jur_Amt, 3Jur_Paid, 3Jur_Due, 3Jur_DtDue, 3Jur_FinalDue, 3Jur_DtPaid, 3Jur_Thru, ";
cmd.CommandText += "4Jur_Yr, 4Jur_Install, 4Jur_Amt, 4Jur_Paid, 4Jur_Due, 4Jur_DtDue, 4Jur_FinalDue, 4Jur_DtPaid, 4Jur_Thru, Jur_PayNotes, Jur_OtherNotes, MillageRate, AssessedValue, LandValue, ImprovedValue, TotalValue, ";
cmd.CommandText += "1Jur_DelAmount, 2Jur_DelAmount, 3Jur_DelAmount, 4Jur_DelAmount, Unincorporated, Ex_Homestead, Ex_Disabled, Ex_Veteran, Ex_Mortgage, Ex_Star, Ex_Elderly, Ex_Other, 1Jur_Del, 2Jur_Del, 3Jur_Del, 4Jur_Del, ";
cmd.CommandText += "DelVerifiedBy, MilNextDue, DelOverideNotes, SpokeTo, LumpSum, SchoolTax, PriorYearDel, 1Jur_Partial, 2Jur_Partial, 3Jur_Partial, 4Jur_Partial, 1Jur_Timely, 2Jur_Timely, 3Jur_Timely, 4Jur_Timely, ";
cmd.CommandText += "1Jur_FrDue, 2Jur_FrDue, 3Jur_FrDue, 4Jur_FrDue, LowestDiscount, PaidDiscount, NoDiscount, PrimaryAuth, OtherAuth, MultiParcel, LandImprov, PriorYearDelq, AnyRedeemed, SpecialAssess, AnyExemptions, ";
cmd.CommandText += "NextYearAssessment, LastYearPaid, TaxSale, TaxRateArea, Ex_OwnerOccupied) ";
cmd.CommandText += "VALUES ";
cmd.CommandText += "("+ r["ControlNumber"] +", "+ r["Jur_ID"] +", '"+ r["Jur_Status"] +"', '"+ r["Jur_Collected"] +"', '"+ r["1Jur_Yr"] +"', '"+ r["1Jur_Install"] +"', "+ r["1Jur_Amt"] +", "+ r["1Jur_Paid"] +", "+ r["1Jur_Due"] +", '"+ r["1Jur_DtDue"] +"', '"+ r["1Jur_FinalDue"] +"', '"+ r["1Jur_DtPaid"] +"', '"+ r["1Jur_Thru"] +"', ";
cmd.CommandText += "'"+ r["2Jur_Yr"] +"', '"+ r["2Jur_Install"] +"', "+ r["2Jur_Amt"] +", "+ r["2Jur_Paid"] +", "+ r["2Jur_Due"] +", '"+ r["2Jur_DtDue"] +"', '"+ r["2Jur_FinalDue"] +"', '"+ r["2Jur_DtPaid"] +"', '"+ r["2Jur_Thru"] +"', '"+ r["3Jur_Yr"] +"', '"+ r["3Jur_Install"] +"', "+ r["3Jur_Amt"] +", "+ r["3Jur_Paid"] +", "+ r["3Jur_Due"] +", '"+ r["3Jur_DtDue"] +"', '"+ r["3Jur_FinalDue"] +"', '"+ r["3Jur_DtPaid"] +"', '"+ r["3Jur_Thru"] +"', ";
cmd.CommandText += "'"+ r["4Jur_Yr"] +"', '"+ r["4Jur_Install"] +"', "+ r["4Jur_Amt"] +", "+ r["4Jur_Paid"] +", "+ r["4Jur_Due"] +", '"+ r["4Jur_DtDue"] +"', '"+ r["4Jur_FinalDue"] +"', '"+ r["4Jur_DtPaid"] +"', '"+ r["4Jur_Thru"] +"', '"+ r["Jur_PayNotes"] +"', '"+ r["Jur_OtherNotes"] +"', "+ r["MillageRate"] +", "+ r["AssessedValue"] +", "+ r["LandValue"] +", "+ r["ImprovedValue"] +", "+ r["TotalValue"] +", ";
cmd.CommandText += ""+ r["1Jur_DelAmount"] +", "+ r["2Jur_DelAmount"] +", "+ r["3Jur_DelAmount"] +", "+ r["4Jur_DelAmount"] +", '"+ r["Unincorporated"] +"', '"+ r["Ex_Homestead"] +"', '"+ r["Ex_Disabled"] +"', '"+ r["Ex_Veteran"] +"', '"+ r["Ex_Mortgage"] +"', '"+ r["Ex_Star"] +"', '"+ r["Ex_Elderly"] +"', '"+ r["Ex_Other"] +"', '"+ r["1Jur_Del"] +"', '"+ r["2Jur_Del"] +"', '"+ r["3Jur_Del"] +"', '"+ r["4Jur_Del"] +"', ";
cmd.CommandText += "'"+ r["DelVerifiedBy"] +"', "+ r["MilNextDue"] +", '"+ r["DelOverideNotes"] +"', '"+ r["SpokeTo"] +"', '"+ r["LumpSum"] +"', '"+ r["SchoolTax"] +"', '"+ r["PriorYearDel"] +"', '"+ r["1Jur_Partial"] +"', '"+ r["2Jur_Partial"] +"', '"+ r["3Jur_Partial"] +"', '"+ r["4Jur_Partial"] +"', '"+ r["1Jur_Timely"] +"', '"+ r["2Jur_Timely"] +"', '"+ r["3Jur_Timely"] +"', '"+ r["4Jur_Timely"] +"', ";
cmd.CommandText += "'"+ r["1Jur_FrDue"] +"', '"+ r["2Jur_FrDue"] +"', '"+ r["3Jur_FrDue"] +"', '"+ r["4Jur_FrDue"] +"', "+ r["LowestDiscount"] +", '"+ r["PaidDiscount"] +"', '"+ r["NoDiscount"] +"', '"+ r["PrimaryAuth"] +"', '"+ r["OtherAuth"] +"', '"+ r["MultiParcel"] +"', '"+ r["LandImprov"] +"', '"+ r["PriorYearDelq"] +"', '"+ r["AnyRedeemed"] +"', '"+ r["SpecialAssess"] +"', '"+ r["AnyExemptions"] +"', ";
cmd.CommandText += ""+ r["NextYearAssessment"] +", '"+ r["LastYearPaid"] +"', '"+ r["TaxSale"] +"', '"+ r["TaxRateArea"] +"', '"+ r["Ex_OwnerOccupied"]+ "'); ";
cmd.ExecuteNonQuery();
}
cmd.CommandText = INSERT INTO `FNF Taxes`(ControlNumber, Jur_ID, Jur_Status, Jur_Collected, 1Jur_Yr, 1Jur_Install, 1Jur_Amt, 1Jur_Paid, 1Jur_Due, 1Jur_DtDue, 1Jur_FinalDue, 1Jur_DtPaid, 1Jur_Thru, 2Jur_Yr, 2Jur_Install, 2Jur_Amt, 2Jur_Paid, 2Jur_Due, 2Jur_DtDue, 2Jur_FinalDue, 2Jur_DtPaid, 2Jur_Thru, 3Jur_Yr, 3Jur_Install, 3Jur_Amt, 3Jur_Paid, 3Jur_Due, 3Jur_DtDue, 3Jur_FinalDue, 3Jur_DtPaid, 3Jur_Thru, 4Jur_Yr, 4Jur_Install, 4Jur_Amt, 4Jur_Paid, 4Jur_Due, 4Jur_DtDue, 4Jur_FinalDue, 4Jur_DtPaid, 4Jur_Thru, Jur_PayNotes, Jur_OtherNotes, MillageRate, AssessedValue, LandValue, ImprovedValue, TotalValue, 1Jur_DelAmount, 2Jur_DelAmount, 3Jur_DelAmount, 4Jur_DelAmount, Unincorporated, Ex_Homestead, Ex_Disabled, Ex_Veteran, Ex_Mortgage, Ex_Star, Ex_Elderly, Ex_Other, 1Jur_Del, 2Jur_Del, 3Jur_Del, 4Jur_Del, DelVerifiedBy, MilNextDue, DelOverideNotes, SpokeTo, LumpSum, SchoolTax, PriorYearDel, 1Jur_Partial, 2Jur_Partial, 3Jur_Partial, 4Jur_Partial, 1Jur_Timely, 2Jur_Timely, 3Jur_Timely, 4Jur_Timely, 1Jur_FrDue, 2Jur_FrDue, 3Jur_FrDue, 4Jur_FrDue, LowestDiscount, PaidDiscount, NoDiscount, PrimaryAuth, OtherAuth, MultiParcel, LandImprov, PriorYearDelq, AnyRedeemed, SpecialAssess, AnyExemptions, NextYearAssessment, LastYearPaid, TaxSale, TaxRateArea, Ex_OwnerOccupied) VALUES (1291922, 1168, '', '', '2013', '1', 452.55, 452.55, , '9/30/2012 12:00:00 AM', '10/1/2012 12:00:00 AM', '9/30/2012 12:00:00 AM', '', '2013', '2', 452.55, 452.55, , '12/31/2012 12:00:00 AM', '1/1/2013 12:00:00 AM', '12/31/2012 12:00:00 AM', '', '2013', '3', 452.55, 452.55, , '3/31/2013 12:00:00 AM', '4/1/2013 12:00:00 AM', '3/31/2013 12:00:00 AM', '', '2013', '4', 452.55, 452.55, , '6/5/2013 12:00:00 AM', '6/6/2013 12:00:00 AM', '6/5/2013 12:00:00 AM', '', '', 'There are no special assessments for this property.', 1.05, 172400, 30000, 142400, 172400, , , , , 'False', 'False', 'False', 'False', 'False', 'False', 'False', '', 'False', 'False', 'False', 'False', '', 9/30/2013 12:00:00 AM, '', '', 'False', 'False', 'False', 'False', 'False', 'False', 'False', 'False', 'False', 'False', 'False', '9/1/2012 12:00:00 AM', '9/1/2012 12:00:00 AM', '9/1/2012 12:00:00 AM', '9/1/2012 12:00:00 AM', , 'False', 'False', 'False', 'Yes', 'No', 'Land and Improvements', 'No', 'No', 'No', 'No', , '', '', '', 'False');