2

I have a VB.NET program that reads a text file and inserts the data into a mdb. The text file is a stream string that is not possible to split, so I need to use substring to get the different fields. The way that the code works now is that the string is substring, then put inserted into different fields in the mdb. But the speed is too slow.

Example: 12345678TomChan 80

  • The first eight digits are the ID
  • The folowing 10 digits are the name
  • The final two digits are mark

This is the string layout and it has about 20000 records.

Is there a faster way to do this?

4

1 回答 1

0

使用 schema.ini 文件并直接导入到 MS Access。

[imp.txt]
ColNameHeader=False
Format=FixedLength
Col1=ID  Char Width 8
Col2=AName  Char Width 10
Col3=Mark Char Width 2

SQL

SELECT * INTO Imp FROM [Text;DATABASE=Z:\docs].[imp.txt]

参考: http: //msdn.microsoft.com/en-us/library/windows/desktop/ms709353 (v=vs.85).aspx

于 2013-02-05T11:51:19.577 回答