2015-03-26 3 views
0

Я пытаюсь изменить записи в моей базе данных Microsoft Access с помощью C# в .NET Framework. Это мой код выполнения, но я продолжаю получать синтаксическую ошибку из своего заявления INSERT и не могу понять, почему, может ли кто-нибудь помочь? Я также испытываю некоторые проблемы, когда инструкция SELECT не возвращает никаких данных, которые я знаю в базе данных. Я занимаюсь этим несколько дней и нуждаюсь в новых глазах, что я могу делать неправильно?Где моя ошибка ввода SQL?

Это ошибка:

Error: System.Data.OleDb.OleDbException (0x80040E14): Syntax error in INSERT INTO statement. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at ABM_Office_System.UpdateABMDatabaseWindow.b__0()...

for (int i = 0; i < hmuFinalList.Count; i++) 
{ 
    Dispatcher.Invoke(() => 
    { 
     stsW.StatusLbl.Content = "Updating " + hmuFinalList[i].MName + "'s records"; 
    }); 
    readcmd.Parameters.Clear(); 
    readcmd.CommandText = "SELECT * FROM [ABM] WHERE [M Name][email protected]"; 
    readcmd.Parameters.AddWithValue("@", hmuFinalList[i].MName); 
    Console.WriteLine("READCMD: " + readcmd.CommandText); 
    Console.WriteLine("ReadcmdTRANSACTION: "); 
    affected = readcmd.ExecuteNonQuery(); 
    Console.WriteLine("affected: " + affected.ToString()); 
    if (affected > 0) //UPDATE TIME! 
    { 
     executecmd.Parameters.Clear(); 
     executecmd.CommandText = "UPDATE [ABM] SET "+ 
     "[M Type][email protected]," + 
     "[M Component][email protected]," + 
     "[M Birth Date][email protected]," + 
     "[M Visa Expiration Date][email protected]," + 
     "[M Residence Nation][email protected]," + 
     "[M MTC][email protected]," + 
     "[M MTC Date][email protected]," + 
     "[M Arrival Date][email protected]," + 
     "[M Release Date][email protected], " + 
     "[M Past Position][email protected]," + 
     "[M Past Position Start Date][email protected]," + 
     "[M Current Position Start Date][email protected]," + 
     "[M Past Area][email protected]," + 
     "[M Past Area Start Date],[email protected]" + 
     "[M Current Area Start Date][email protected]," + 
     "[M Title - English][email protected]," + 
     "[M Title - Non-English][email protected]," + 
     "[M HMU Correspondent Type][email protected]," + 
     "[M HMU Correspondent Last Name][email protected]," + 
     "[M HMU Correspondent Given Name][email protected]," + 
     "[M HMU Correspondent Language][email protected]," + 
     "[M HMU Correspondent Comment][email protected]," + 
     "[M HMU Correspondent Title][email protected]," + 
     "[M HMU Correspondent Relationship][email protected]," + 
     "[M HMU Correspondent Pronoun - Subject][email protected]," + 
     "[M HMU Correspondent Pronoun - Object][email protected]," + 
     "[M HMU Correspondent Pronoun - Possessive][email protected]," + 
     "[M HMU Correspondent Pronoun - Other][email protected]," + 
     "[M Previous Address Line 1][email protected]," + 
     "[M Previous Address City][email protected]," + 
     "[M Previous Address State/Province][email protected]," 
     + "[M Previous Address Postal Code][email protected]," + 
     "[M Previous Address Country][email protected]," + 
     "[M Type Plural][email protected]," + 
     "[M Transfer Effective Date][email protected]," + 
     "[M Position is a Promotion][email protected]," + 
     "[M HMU Correspondent Pronoun Cap - Subject][email protected]," + 
     "[M HMU Correspondent Pronoun Cap - Object][email protected]," + 
     "[M HMU Correspondent Pronoun Cap - Possessive][email protected]," + 
     "[M HMU Correspondent Pronoun Cap - Other][email protected]," + 
     "[M HMU Correspondent Title - Envelope][email protected]," + 
     "[M Where Born][email protected]" + 
     "WHERE [M Name][email protected]"; 

     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MType) ? (object)DBNull.Value : hmuFinalList[i].MType); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MComponent) ? (object)DBNull.Value : hmuFinalList[i].MComponent); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MBirthDate) ? (object)DBNull.Value : hmuFinalList[i].MBirthDate); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MVisaExpirationDate) ? (object)DBNull.Value : hmuFinalList[i].MVisaExpirationDate); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MResidenceNation) ? (object)DBNull.Value : hmuFinalList[i].MResidenceNation); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MMTC) ? (object)DBNull.Value : hmuFinalList[i].MMTC); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MMTCDate) ? (object)DBNull.Value : hmuFinalList[i].MMTCDate); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MArrivalDate) ? (object)DBNull.Value : hmuFinalList[i].MArrivalDate); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MReleaseDate) ? (object)DBNull.Value : hmuFinalList[i].MReleaseDate); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MPastPosition) ? (object)DBNull.Value : hmuFinalList[i].MPastPosition); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MPastPositionStartDate) ? (object)DBNull.Value : hmuFinalList[i].MPastPositionStartDate); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MCurrentPositionStartDate) ? (object)DBNull.Value : hmuFinalList[i].MCurrentPositionStartDate); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MPastArea) ? (object)DBNull.Value : hmuFinalList[i].MPastArea); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MPastAreaStartDate) ? (object)DBNull.Value : hmuFinalList[i].MPastAreaStartDate); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MCurrentAreaStartDate) ? (object)DBNull.Value : hmuFinalList[i].MCurrentAreaStartDate); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MTitleEnglish) ? (object)DBNull.Value : hmuFinalList[i].MTitleEnglish); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MTitleNonEnglish) ? (object)DBNull.Value : hmuFinalList[i].MTitleNonEnglish); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentType) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentType); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentLastName) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentLastName); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentGivenName) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentGivenName); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentLanguage) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentLanguage); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentComment) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentComment); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentTitle) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentTitle); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentRelationship) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentRelationship); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounSubject) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounSubject); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounObject) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounObject); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounPossessive) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounPossessive); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounOther) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounOther); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MPreviousAddressLine1) ? (object)DBNull.Value : hmuFinalList[i].MPreviousAddressLine1); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MPreviousAddressCity) ? (object)DBNull.Value : hmuFinalList[i].MPreviousAddressCity); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MPreviousAddressStateProvince) ? (object)DBNull.Value : hmuFinalList[i].MPreviousAddressStateProvince); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MPreviousAddressPostalCode) ? (object)DBNull.Value : hmuFinalList[i].MPreviousAddressPostalCode); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MPreviousAddressCountry) ? (object)DBNull.Value : hmuFinalList[i].MPreviousAddressCountry); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MTypePlural) ? (object)DBNull.Value : hmuFinalList[i].MTypePlural); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MTransferEffectiveDate) ? (object)DBNull.Value : hmuFinalList[i].MTransferEffectiveDate); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MPositionisaPromotion) ? (object)DBNull.Value : hmuFinalList[i].MPositionisaPromotion); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounCapSubject) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounCapSubject); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounCapObject) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounCapObject); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounCapPossessive) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounCapPossessive); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounCapOther) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounCapOther); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].CorrespondentTitleEnvelope) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentTitleEnvelope); 
     executecmd.Parameters.AddWithValue("@", string.IsNullOrEmpty(hmuFinalList[i].MWhereBorn) ? (object)DBNull.Value : hmuFinalList[i].MWhereBorn); 
     executecmd.Parameters.AddWithValue("@", hmuFinalList[i].MName); 
     Console.WriteLine("HMU UPDATE EXECUTION: " + executecmd.CommandText); 
     executecmd.ExecuteNonQuery(); 
    } 
    else //INSERT TIME! 
    { 
     executecmd.Parameters.Clear(); 
     executecmd.CommandText = "INSERT INTO [ABM] ([M Name],[M Type],[M Component],[M Birth Date],[M Visa Expiration Date],[M Residence Nation],"+ 
     "[M MTC]," + 
     "[M MTC Date],"+ 
     "[M Arrival Date],"+ 
     "[M Release Date], "+ 
     "[M Past Position],"+ 
     "[M Past Position Start Date]," + 
     "[M Current Position Start Date]," + 
     "[M Past Area],"+ 
     "[M Past Area Start Date],"+ 
     "[M Current Area Start Date],"+ 
     "[M Title - English],"+ 
     "[M Title - Non-English],"+ 
     "[M HMU Correspondent Type],"+ 
     "[M HMU Correspondent Last Name]," + 
     "[M HMU Correspondent Given Name]," + 
     "[M HMU Correspondent Language]," + 
     "[M HMU Correspondent Comment]," + 
     "[M HMU Correspondent Title]," + 
     "[M HMU Correspondent Address Line 1]," + 
     "[M HMU Correspondent Relationship]," + 
     "[M HMU Correspondent Pronoun - Subject]," + 
     "[M HMU Correspondent Pronoun - Object]," + 
     "[M HMU Correspondent Pronoun - Possessive]," + 
     "[M HMU Correspondent Pronoun - Other]," + 
     "[M Previous Address Line 1],"+ 
     "[M Previous Address City]," + 
     "[M Previous Address State/Province],"+ 
     "[M Previous Address Postal Code]," + 
     "[M Previous Address Country],"+ 
     "[M Type Plural]," + 
     "[M Transfer Effective Date],"+ 
     "[M Position is a Promotion]," + 
     "[M HMU Correspondent Pronoun Cap - Subject]," + 
     "[M HMU Correspondent Pronoun Cap - Object]," + 
     "[M HMU Correspondent Pronoun Cap - Possessive]," + 
     "[M HMU Correspondent Pronoun Cap - Other]," + 
     "[M HMU Correspondent Title - Envelope]," + 
     "[M Where Born],)"+ 
     "VALUES(@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@,@)"; 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MName) ? (object)DBNull.Value : hmuFinalList[i].MName); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MType) ? (object)DBNull.Value : hmuFinalList[i].MType); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MComponent) ? (object)DBNull.Value : hmuFinalList[i].MComponent); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MBirthDate) ? (object)DBNull.Value : hmuFinalList[i].MBirthDate); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MVisaExpirationDate) ? (object)DBNull.Value : hmuFinalList[i].MVisaExpirationDate); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MResidenceNation) ? (object)DBNull.Value : hmuFinalList[i].MResidenceNation); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MMTC) ? (object)DBNull.Value : hmuFinalList[i].MMTC); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MMTCDate) ? (object)DBNull.Value : hmuFinalList[i].MMTCDate); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MArrivalDate) ? (object)DBNull.Value : hmuFinalList[i].MArrivalDate); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MReleaseDate) ? (object)DBNull.Value : hmuFinalList[i].MReleaseDate); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MPastPosition) ? (object)DBNull.Value : hmuFinalList[i].MPastPosition); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MPastPositionStartDate) ? (object)DBNull.Value : hmuFinalList[i].MPastPositionStartDate); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MCurrentPositionStartDate) ? (object)DBNull.Value : hmuFinalList[i].MCurrentPositionStartDate); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MPastArea) ? (object)DBNull.Value : hmuFinalList[i].MPastArea); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MPastAreaStartDate) ? (object)DBNull.Value : hmuFinalList[i].MPastAreaStartDate); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MCurrentAreaStartDate) ? (object)DBNull.Value : hmuFinalList[i].MCurrentAreaStartDate); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MTitleEnglish) ? (object)DBNull.Value : hmuFinalList[i].MTitleEnglish); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MTitleNonEnglish) ? (object)DBNull.Value : hmuFinalList[i].MTitleNonEnglish); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentType) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentType); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentLastName) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentLastName); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentGivenName) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentGivenName); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentLanguage) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentLanguage); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentComment) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentComment); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentTitle) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentTitle); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentAddressLine1) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentAddressLine1); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentRelationship) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentRelationship); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounSubject) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounSubject); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounObject) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounObject); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounPossessive) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounPossessive); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounOther) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounOther); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MPreviousAddressLine1) ? (object)DBNull.Value : hmuFinalList[i].MPreviousAddressLine1); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MPreviousAddressCity) ? (object)DBNull.Value : hmuFinalList[i].MPreviousAddressCity); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MPreviousAddressStateProvince) ? (object)DBNull.Value : hmuFinalList[i].MPreviousAddressStateProvince); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MPreviousAddressPostalCode) ? (object)DBNull.Value : hmuFinalList[i].MPreviousAddressPostalCode); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MPreviousAddressCountry) ? (object)DBNull.Value : hmuFinalList[i].MPreviousAddressCountry); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MTypePlural) ? (object)DBNull.Value : hmuFinalList[i].MTypePlural); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MTransferEffectiveDate) ? (object)DBNull.Value : hmuFinalList[i].MTransferEffectiveDate); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MPositionisaPromotion) ? (object)DBNull.Value : hmuFinalList[i].MPositionisaPromotion); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounCapSubject) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounCapSubject); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounCapObject) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounCapObject); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounCapPossessive) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounCapPossessive); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentPronounCapOther) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentPronounCapOther); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].CorrespondentTitleEnvelope) ? (object)DBNull.Value : hmuFinalList[i].CorrespondentTitleEnvelope); 
     executecmd.Parameters.AddWithValue("@",string.IsNullOrEmpty(hmuFinalList[i].MWhereBorn) ? (object)DBNull.Value : hmuFinalList[i].MWhereBorn); 
     Console.WriteLine("HMU INSERT EXECUTION: " + executecmd.CommandText); 
     executecmd.ExecuteNonQuery(); 
    } 

} 

Это сводит меня с ума!

+2

Там есть дополнительная запятая на последней строке: '[M Где Born])' – David

+0

Я редактировал свой титул. Пожалуйста, смотрите: «Если вопросы включают« теги »в их названиях?] (Http://meta.stackexchange.com/questions/19190/), где консенсус« нет, они не должны ». –

+2

Когда у меня возникают проблемы со сложным оператором SQL, я обычно собираю финальную строку sql, созданную непосредственно перед ее выполнением, и пытаюсь запустить ее непосредственно в базе данных. Иногда это делает ошибки более ясными. – CindyH

ответ

1

Ваш список столбцов вставки заканчивается запятой, когда он не должен.

Заменить

 "[M Where Born],)"+ 

С

 "[M Where Born])"+ 
Смежные вопросы