简体   繁体   English

VB.Net将文本文件附加到访问MDB中

[英]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. 我有一个VB.NET程序,该程序读取文本文件并将数据插入到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. 现在,代码的工作方式是字符串为子字符串,然后将其插入mdb中的不同字段。 But the speed is too slow. 但是速度太慢了。

Example: 12345678TomChan 80 示例: 12345678TomChan 80

  • The first eight digits are the ID 前八位数字是ID
  • The folowing 10 digits are the name 后面的10位数字是名字
  • The final two digits are mark 最后两位数字是mark

This is the string layout and it has about 20000 records. 这是字符串布局,大约有20000条记录。

Is there a faster way to do this? 有更快的方法吗?

Use a schema.ini file and a straight import to MS Access. 使用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 的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 参考: http : //msdn.microsoft.com/zh-cn/library/windows/desktop/ms709353(v=vs.85).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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