Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. to read from a notepad file line by line and insert each line into one table

to read from a notepad file line by line and insert each line into one table

Scheduled Pinned Locked Moved C#
csharpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    George Mathew
    wrote on last edited by
    #1

    i have a txt file with 1000 names and a table with two fields, id and NAME. i want to read the contents from the txt file line by line and insert each line to the name field of the table.. how can i implements this using c#.. George Mathew

    D M 2 Replies Last reply
    0
    • G George Mathew

      i have a txt file with 1000 names and a table with two fields, id and NAME. i want to read the contents from the txt file line by line and insert each line to the name field of the table.. how can i implements this using c#.. George Mathew

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      Use this example from MSDN and do your DB inserts instead of Console.WriteLine http://msdn2.microsoft.com/en-us/library/aa287535(VS.71).aspx[^]

      L 1 Reply Last reply
      0
      • G George Mathew

        i have a txt file with 1000 names and a table with two fields, id and NAME. i want to read the contents from the txt file line by line and insert each line to the name field of the table.. how can i implements this using c#.. George Mathew

        M Offline
        M Offline
        M Riaz Bashir
        wrote on last edited by
        #3

        Hi, I am already using this command. Using System.IO; FileStream fileStreamMainINI = new FileStream("MYWORK.TXT", FileMode.OpenOrCreate, FileAccess.Read); StreamReader srMainINI = new StreamReader(fileStreamMainINI); string strLineValue = null; while (srMainINI.Peek() > -1) { strLineValue = srMainINI.ReadLine(); // and then you may use this string value anywhere }

        1 Reply Last reply
        0
        • D DaveyM69

          Use this example from MSDN and do your DB inserts instead of Console.WriteLine http://msdn2.microsoft.com/en-us/library/aa287535(VS.71).aspx[^]

          L Offline
          L Offline
          Larantz
          wrote on last edited by
          #4

          DaveyM69 wrote:

          and do your DB inserts instead of Console.WriteLine

          :-D -Larantz-

          for those about to code, we salute you
          http://www.itverket.no

          Please refer to the Forum Guidelines for appropriate posting.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups