473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Loading TXT to DB (VB)

I have large TEXT files (less than 50MB) that I want to load into
MSSQL. Each line has to be extracted, parsed and then inserted into the
DB. What's the best way of doing this?

Currently I extract each line, parse it and then INSERT it into the DB.
I am not using any DataSet/DataGrids. I have one db connection always
open for this process. The problem is that this takes almost half an
hour to finish. I'm wondering if using a DataSet would be beneficial
for me.

Any help would be appreciated!

Nov 21 '05 #1
5 1147
You didn't mention what version of SQL server you are using, but do you
need to go through an application at all? You could instead set up a
DTS in SQL that imports from a text file to your SQL database.

To activate the DTS, you could run it with the SQL's Job Scheduler, or
use DTS objects from your .NET application.

Nov 21 '05 #2
"Data" <da***********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I have large TEXT files (less than 50MB) that I want to load into
MSSQL. Each line has to be extracted, parsed and then inserted into
the DB. What's the best way of doing this?


For anything more than a few thousand rows at a time, I'd tackle this
as a two-stage process:

1) Read the file, parse the data and write it to /another/ file,
ready for...
2) Use the bcp utility to read this second file and slam it into
SQLServer - much, *much* faster.

HTH,
Phill W.
Nov 21 '05 #3
>I have large TEXT files (less than 50MB) that I want to load into
MSSQL. Each line has to be extracted, parsed and then inserted into the
DB. What's the best way of doing this?
Lookup the BULK INSERT statement in SQL Server Books Online.

Make a "Work-Table" that has the same structure as your TXT file. Not a
Temp Table, a Real one.
I am not using any DataSet/DataGrids. I have one db connection always
open for this process. The problem is that this takes almost half an
hour to finish.


The system that I inherited processes .txt files in excess of 500MB in less
than a half hour. Our SQL Server is a 4 CPU XEON with 3 gigs of RAM. We
load several dozen of these files all at once, on a quarterly basis.

--
Peace & happy computing,

Mike Labosh, MCSD

"When you kill a man, you're a murderer.
Kill many, and you're a conqueror.
Kill them all and you're a god." -- Dave Mustane
Nov 21 '05 #4
The server is MSSQL. And unfortunately, I can't use bcp or DTS because
there are several text files that require parsing and are contingent
upon each other.

The solution has to be in such order:

File > Manipulate contents > DB

Nov 21 '05 #5
Don't worry about this. I will post the method that I used so that
others can benifit from it.

I inserted the text files contents into a single column DataSet table
and then parsed one-by-one into the database. I was able to do a 32MB
text file within 7 minutes.

Alternatively, with the original method that I had which was to read
each line from the file, parse it and then insert it into the db was
taking around 20 minutes to do.

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Matthew | last post by:
I am not the most talented programmer to grace the earth by a long shot. But I've got a gripe I need to air about the .NET implementaion of Visual Basic. I can live with alot of the major changes...
6
by: Organza | last post by:
Good morning. Im building a little utility that load dll and show me all his properties and methods. somthing like the object browser. but i have a big problem with it. when im loading a .net...
2
by: Rob | last post by:
I was working on a project and everything was going fine, then all of a sudden the form set as my startup object stopped loading. I tried setting some others as the startup object, and some of my...
1
by: RAJ | last post by:
Hi, I am working on a source code written earlier in VB.net.While loading some forms(already created with some controls on it), I am getting the following error:...
3
by: Holmes | last post by:
Hello Ran into a bit of a problem here and have now exhausted my resources to getting this working What I am trying to do is load and show a simple vb form with a listbox in it Dim...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
6
by: Pieter | last post by:
Hi, I developed an Outlook Add In (VB.NET 2005, for Outlook 2003) that sometimes suddenly stops loading. I've put everywhere in the code Exception Handlers, but no Exception is catched. it...
0
by: Mark | last post by:
I am converting a VB6/COM application to VB.NET and must remove all COM objects. VB6/COM App Architecture: Windows Form hosts WebBrowser which loads HTML snippets from local disk. Some of the...
3
by: steven | last post by:
Hello, As anyone knows, before starting up a .Net application, parts of the ..Net framework must be loaded in memory. Therefore, starting this application can last for quite a few seconds...
0
by: nav010 | last post by:
Hello Everybody I am trying to load vb.net dll in Python, but its showing errors. >>> from ctypes import * >>> dll = windll.Userdll >>> dll <WinDLL 'Userdll', handle 1050000 at cade50> >>>...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.