You must Sign In to post a response.
  • Category: [Competition Entries]

    Special charactor in txt file need to be insert into database without special charactor

    Are you looking for information on insert functionality? Want to know how to insert special character of txt file into database without special character? Then read this thread to learn more about it.

    i have txt file which is have the data like ~~~~~~~~~~~~sameer i need insert only data in my database sql server back end front end language C#

    this is import functionlaity
  • #739704
    Do you want to remove the special character from the data you are inserting or you want to add them

    Please specify it clearly.

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #739725
    yes i have txt file which is exist the data with ~~sam~~goregoa~~~~lion~~~~989898989898~~~~

    in this sequence i need to import this file in my sql server like

    (Field)name address animal number
    sam goregaon lion 989898989898

  • #739726
    i need to upload with the help of upload dialog in

  • #739734
    just take a given string in 'string' variable and use 'replace' method of string to replace special character with EMPTY sapce and then insert it in database, see below code snippet

    string szMsg = "~~~~~~~~~~~~sameer";
    string szFinalOutput = szMsg.Replace("~","");
    //you make take different special characters
    string szFinalOutput = szMsg.Replace("!","");
    string szFinalOutput = szMsg.Replace("#","");
    string szFinalOutput = szMsg.Replace("$","");
    string szFinalOutput = szMsg.Replace("%","");
    string szFinalOutput = szMsg.Replace("^","");

    Alternatively you can add all special characters in an array and then loop on that array to replace special characters
    hope it helps

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #739767
    i need to upload with the help of upload dialog in

  • #739769
    i need code for can please send it to me

  • #740128
    Hai Sameer,
    Wherever you need whether in ASP.Net or C#, the method will be same.
    You just need to use the logic which will replace the special characters to blank so that all the special characters will be removed from the string.
    First you need to find out that what all the special characters you want to remove. Lie if it is the email address then you should not replace the "@" and ".". Like this, you can find the other special characters and then use the logic to replace it with the empty character.
    But if you are having the data and you want to extract it as per your table definition, then you need to split it as below:

    string input="~~sam~~goregoa~~~~lion~~~~989898989898~~~~";
    string[] split= input.Split("~");
    string name = split[0];
    string address = split[1];
    string animal= split[2];
    string phone = split[3];

    Now you can use this details.
    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • Sign In to post your comments