locked
bulk excel data insertion into sql with encrpttion in C# RRS feed

  • Question

  • User87195929 posted

    Hi

    I want to insert the bulk excel records in to sql  with encryption using C#

    and also i want to Decrption the data while i  retrving in C#.

    thanks and regards

    siddu

    Monday, January 29, 2018 2:31 PM

All replies

  • User-832373396 posted

    <g class="gr_ gr_11 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep" id="11" data-gr-id="11">Hi</g> siddangoud,

    insert the bulk excel records <g class="gr_ gr_66 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="66" data-gr-id="66">in to</g> sql

    In Excel, select File | Save As and then select Text (Tab delimited) (*.txt) or CSV (Comma delimited) (*.csv) as the destination file type.

    The following example loads the data from <g class="gr_ gr_81 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="81" data-gr-id="81">the</g><g class="gr_ gr_81 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Style multiReplace" id="81" data-gr-id="81"> </g>Data.csv<g class="gr_ gr_81 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Style multiReplace" id="81" data-gr-id="81"> </g><g class="gr_ gr_81 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Style multiReplace" id="81" data-gr-id="81">comma-delimited</g> file into an existing database table.

    USE ImportFromExcel;
    GO
    BULK INSERT Data_bi FROM 'D:\Desktop\data.csv'
       WITH (
          FIELDTERMINATOR = ',',
          ROWTERMINATOR = '\n'
    );
    GO

    Guide

    with encryption using C#
     

    <g class="gr_ gr_131 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="131" data-gr-id="131">Decrption</g> the data while <g class="gr_ gr_139 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="139" data-gr-id="139">i</g>  <g class="gr_ gr_132 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="132" data-gr-id="132">retrving</g> in C#.

    ep.

    Enable the encryption of parameters, and the decryption of query results targeting the encrypted <g class="gr_ gr_135 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-del replaceWithoutSep" id="135" data-gr-id="135">columns,</g> is by setting the value of the Column Encryption Setting connection string keyword to enabled.

    SqlConnectionStringBuilder strbldr = new SqlConnectionStringBuilder();
    strbldr.DataSource = "server63";
    strbldr.InitialCatalog = "Clinic";
    strbldr.IntegratedSecurity = true;
    strbldr.ColumnEncryptionSetting = SqlConnectionColumnEncryptionSetting.Enabled;
    SqlConnection connection = new SqlConnection(strbldr.ConnectionString); 

    Guide

    Reference:

    With regards, Angelina Jolie

    Tuesday, January 30, 2018 8:13 AM