locked
Error-the given value of type String from the data source cannot be converted to type nvarchar of the specified target column. RRS feed

  • Question

  • User-1499457942 posted

    Hi

      I am getting above error when importing data from excel to sql

    Thanks

    Sunday, July 15, 2018 9:10 AM

Answers

  • User753101303 posted

    Hi,

    See for example https://forums.asp.net/p/1228890/2212376.aspx

    More likely the length of the target column is not wide enough to accept one of string found in the Excel file.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 15, 2018 9:52 AM
  • User-369506445 posted

    hi

    • ENSURE provided value is valid for the destination type.
    • CREATE column by specifying the type to get the error before executing <g class="gr_ gr_8 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" id="8" data-gr-id="8">WriteToServer</g> method.
    var dt = new DataTable();
    dt.Columns.Add("TheColumnInt", typeof(int));
    dt.Columns.Add("TheColumnString", typeof(string));

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 15, 2018 10:07 AM

All replies

  • User753101303 posted

    Hi,

    See for example https://forums.asp.net/p/1228890/2212376.aspx

    More likely the length of the target column is not wide enough to accept one of string found in the Excel file.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 15, 2018 9:52 AM
  • User-369506445 posted

    hi

    • ENSURE provided value is valid for the destination type.
    • CREATE column by specifying the type to get the error before executing <g class="gr_ gr_8 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" id="8" data-gr-id="8">WriteToServer</g> method.
    var dt = new DataTable();
    dt.Columns.Add("TheColumnInt", typeof(int));
    dt.Columns.Add("TheColumnString", typeof(string));

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 15, 2018 10:07 AM