Solved Import text file into SQL table

Posted on 2014-11-25
Last Modified: 2014-11-25

I use SQL Server Management Studio to import text files into my SQL table.
I now want to do this programmatically in my Windows Forms app.
What code would I use to do this?
Question by:murbro
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3

Expert Comment

ID: 40464384
How big of a text file?   I been reading the text file into and then inserting each line via sql statement.
LVL 70

Expert Comment

by:Éric Moreau
ID: 40464387
Have a look at the free FileHelpers library to read your files:

Author Comment

ID: 40464392
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.


Author Comment

ID: 40464400
Incidentally, my project is an Excel add-in. Would it be a good idea to perhaps open the .csv or .txt file in Excel the run code to create a dataset/datatable from Excel
LVL 70

Expert Comment

by:Éric Moreau
ID: 40464403
What I don't like about Excel is that it will try to convert some fields for you and the result is not always accurate. I prefer to process raw files.
LVL 70

Accepted Solution

Éric Moreau earned 500 total points
ID: 40464407
As for your other link, there are so many ways of reading/processing files that it will depend on your actual needs and mostly your data files (header or not, formatted or not, ...)

I find myself using a combination of multiple methods because I never found one solution to fit all the files I have to process for one of my clients.

Author Closing Comment

ID: 40464469
Thanks very much Eric. I hadn't realised how complicated this process is

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question