Click here to Skip to main content
14,641,269 members

help me:-read string frm text file & store into BD asked:

Open original thread
Help me to solve this problm
i have to read string text file and split it by comma and finaly save it into database.....
ex:--In text file : suhas,kumar,55555,male,22.
i have to store this data into database...
then again read next line....

private void split()

    StreamReader rd1 = new StreamReader("c:\\temp1.txt");//string is suhas,kumar,8888888888,male.
    string str12 = rd1.ReadLine();
    string[] str1 = str12.Split(',');
    // splitmsg(str1);
    foreach (string part in str1)
       //display array string


how can i use values in insert query..
Tags: C#, SQL-Server


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100