Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 539
  • Last Modified:

VB.net Import text file into SQL table

Hi

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?
Thanks
0
Murray Brown
Asked:
Murray Brown
  • 3
  • 3
1 Solution
 
edwardqCommented:
How big of a text file?   I been reading the text file into vb.net and then inserting each line via sql statement.
0
 
Éric MoreauSenior .Net ConsultantCommented:
Have a look at the free FileHelpers library to read your files: http://emoreau.com/Entries/Articles/2011/11/Using-the-FileHelpers-Library.aspx
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
0
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!

 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
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
0
 
Éric MoreauSenior .Net ConsultantCommented:
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.
0
 
Éric MoreauSenior .Net ConsultantCommented:
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.
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much Eric. I hadn't realised how complicated this process is
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now