简体   繁体   中英

VB.Net append text file into access mdb

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?

Use a schema.ini file and a straight import to 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]

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM