Libor Zapletal
Libor Zapletal

Reputation: 14102

C# - Best (fastest) way to import data from text file to mdf

I need to import data from text file (not separeted by commas, other way, different characters) to database (for example to mdf). Because datagridview loads data from database faster then from file. What is the best way? Thank you

Upvotes: 1

Views: 2027

Answers (2)

bob
bob

Reputation: 6485

Maybe the .NET library FileHelpers can do something for you...

Upvotes: 0

Martin
Martin

Reputation: 40365

If using SQL Server (which .mdf suggests you are) you could try bulk inserting:

BULK
INSERT MyTable
FROM 'c:\myfile.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)

Upvotes: 2

Related Questions