VB.net Import text file into SQL table

Posted on 2014-11-25
Medium Priority
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 VB.net code would I use to do this?
Question by:Murray Brown
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 vb.net 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: http://emoreau.com/Entries/Articles/2011/11/Using-the-FileHelpers-Library.aspx

Author Comment

by:Murray Brown
ID: 40464392
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

by:Murray Brown
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 2000 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

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

741 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