Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7654589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:17:40+00:00 2026-05-31T12:17:40+00:00

I am inserting bulk data(serial number,pin number) to DB.Before inserting,the data from datatable is

  • 0

I am inserting bulk data(serial number,pin number) to DB.Before inserting,the data from datatable is binded into XML tag.Here the pin number is encrypted one…as follows,

strXml = "<?xml<pre lang="c#"></pre> version=" + @"""1.0"" encoding=" + @"""iso-8859-1""?><batch>";
strPinXml =strPinXml + "<data cardid="+@"""" +strid+@""""+" pinnumber=" + @"""" + myRC4Engine.CryptedText + @"""" + "></data>";
strXml = strXml + strPinXml + "</batch>";

Problem is after inserting into db, to verify whether the actual pinnumber(encrypted format in db) is inserted, i decrypted the pinnumber and found that,

The first digit in all data are displaced by (’)single quote and last
digit for some pinnumber is empty (if the pinnumber is-œA_¡/Ì·ÞvËÛ
(ie)ending in Û for that pins last digit is empty).


Please note that i’am using SQL server 2000 in this application

Please provide the solution to resolve this issue

Result as follows

Pins before inserting into db

  • Pinnumber(While inserting)
    • (Encrypted format) — (Decrypted format)
    • šA [¦,ȵØzËÚ ——— 7613051524692
    • œA ¡/Ì•ÞvËÛ ——— 1687765748683
    • ™@ X¦!Ï´ÝÎÛ ——— 4770086471383
    • žA Z¡+ɹÝwÏÒ ——— 3642720979218
    • •O Q¢(˹Þ{ËÛ ——— 8879412945686
    • ŸO^¡,ȶÝ}Î× ——— 2846751673342

Pins retrieved from db after insertion

  • Pinnumber (Retrieved from db) —- Retrieved pinnumber
    • (Encrypted format) ————— (Decrypted format)
    • A [¦,ȵØzËÚ ——————- ’613051524692
    • A _¡/Ì•ÞvËÛ ——————- ’68776574868
    • @ X¦!Ï´ÝÎÛ —————— ’77008647138
    • A Z¡+ɹÝwÏÒ —————– ’642720979218
    • O Q¢(˹Þ{ËÛ ——————- ’879412945686
    • O ^¡,ȶÝ}Î× —————— ’846751673342

Application coding as follows

try
{
    RC4Engine myRC4Engine = new RC4Engine();
    myRC4Engine.EncryptionKey = "ab48495fdjk4950dj39405fk";

    strXml = "<?xml version=" + @"""1.0"" encoding=" + @"""iso-8859-1""?> <batch>";

    foreach (DataRow lobjbaseBatchDetail in dt.Rows)
    {
        myRC4Engine.InClearText = lobjbaseBatchDetail[3].ToString();
        myRC4Engine.Encrypt();

        strCardid = lobjbaseBatchDetail[0].ToString();
        strBatchid = lobjbaseBatchDetail[1].ToString();
        strid = strCardid + strBatchid + lobjbaseBatchDetail[2].ToString();
        strPinXml =strPinXml + "<data cardid="+@"""" +strid+@""""+
                " pinnumber=" + @"""" + myRC4Engine.CryptedText + @"""" + "></data>";
    }
        strXml = strXml + strPinXml + "</batch>";
        SqlParameter[] arrParam = new SqlParameter[1];

        arrParam[0] = new SqlParameter("@BATCHUPLOAD_XML", SqlDbType.Text );
        arrParam[0].Direction = ParameterDirection.Input;
        arrParam[0].Value = strXml;

        iResult = SqlHelper.ExecuteNonQuery(objTrans, CommandType.StoredProcedure, "test_proc", arrParam);
        objTrans.Commit();
}
catch(Exception ex)
{
    objTrans.Rollback();
    throw new Exception("Upload failed :" + ex.Message);
}           

procedure

create procedure test_proc
(
    @BATCHUPLOAD_XML text
)
as
begin
    DECLARE @idoc INT
    EXEC sp_xml_preparedocument @idoc OUTPUT, @BATCHUPLOAD_XML
    insert into test_table_new
    SELECT cardid,pinnumber
    FROM OPENXML (@idoc, '/batch/data')
    WITH (cardid varchar(100) '@cardid', pinnumber nvarchar(200) '@pinnumber')
    EXEC sp_xml_removedocument @idoc
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:17:41+00:00Added an answer on May 31, 2026 at 12:17 pm

    You shouldn’t write the xml by hand. Let C#’s LinqToXml do it for you and it won’t make mistakes.

    You could write it like:

    try
    {
        RC4Engine myRC4Engine = new RC4Engine();
        myRC4Engine.EncryptionKey = "ab48495fdjk4950dj39405fk";
    
        XDocument doc = new XDocument(
            new XDeclaration("1.0", "iso-8859-1", null),
            new XElement("batch"));
    
        foreach (DataRow lobjbaseBatchDetail in dt.Rows)
        {
            myRC4Engine.InClearText = lobjbaseBatchDetail[3].ToString();
            myRC4Engine.Encrypt();
    
            strCardid = lobjbaseBatchDetail[0].ToString();
            strBatchid = lobjbaseBatchDetail[1].ToString();
            strid = strCardid + strBatchid + lobjbaseBatchDetail[2].ToString();
            XElement data = new XElement("data");
            data.Add(new XAttribute("cardid", strid));
            data.Add(new XAttribute("pinnumber", myRC4Engine.CryptedText));
            doc.Root.Add(data);
        }
            SqlParameter[] arrParam = new SqlParameter[1];
    
            arrParam[0] = new SqlParameter("@BATCHUPLOAD_XML", SqlDbType.Text );
            arrParam[0].Direction = ParameterDirection.Input;
            arrParam[0].Value = doc.Declaration.ToString() +
                                doc.ToString(SaveOptions.DisableFormatting);
    
            iResult = SqlHelper.ExecuteNonQuery(objTrans, CommandType.StoredProcedure, "test_proc", arrParam);
            objTrans.Commit();
    }
    catch(Exception ex)
    {
        objTrans.Rollback();
        throw new Exception("Upload failed :" + ex.Message);
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing a bulk insert but before inserting into the actual table I need
Say i am inserting the data into the database using bulk insert that is
I'm trying to insert some data from a XML document into a variable table.
Is there any way to speed up bulk inserting in 2005? I'm looking into
Inserting rows one by one from a 600 record data-set is taking almost an
When inserting copy into an HTML document I get from sources such as word
I'm inserting multiple records into a table A from another table B. Is there
Apart from just inserting and parsing text into a blank Word field, is there
Right. I was inserting a load of data into a MySQL DB and used
I need to bulk load a large amount of data (about 7.000.000 entries) into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.