C# - Best (fastest) way to import data from text file to mdf
I need to import data from text file (not separet开发者_如何学Goed 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
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'
)
Maybe the .NET library FileHelpers can do something for you...
精彩评论