开发者

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

开发者 https://www.devze.com 2023-01-27 02:30 出处:网络
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 th

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...

0

精彩评论

暂无评论...
验证码 换一张
取 消