SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Nov 2005
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reading CSV File and Store its content to SQL DB (LINQ and WCF)

    Hi anyone know how to read csv file and store its content to sql db using LINQ and WCF, I read few articles but i can't able to comprehend. I am looking for a beginner tutorial.
    Below are the articles I found:
    1. http://www.codeproject.com/Articles/...in-a-WCF-Servi
    2. http://www.dotnetfunda.com/articles/...with-linq.aspx

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2011
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could start off with a .net console app or a web app anything that is convenient. The code will be the same in WCF.
    It'd be a good idea to split your requirements & then go for it. something like
    1 read a file from the disk.
    2 have that file in a datatable , generic list or something like that.
    3 save a datatable/ List to a database

    To get started , here's how you can read a fie using LINQ.
    Code:
     var mycsv =  from x in File.ReadAllLines("D:\\mycsvfile.csv") select x;

  3. #3
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,576
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Only tricky part is parsing the CSV here -- check out FileHelpers, it solves that for you.

    You probably want to skip WCF if you are just reading a CSV file and stuffing it in a database. Unless the database is on a remote host.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •