从文件夹中读取文本文件,然后在vb.net中创建一个访问数据库 [英] Read text file from a folder and then make a access database in vb.net

查看:160
本文介绍了从文件夹中读取文本文件,然后在vb.net中创建一个访问数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


如何通过读取文本文件使vb.net中的数据库访问。我有一个文件夹,其中包含许多文本文件。每个文本文件名都是醋栗日期。



how to make database in access in vb.net from reading text files.i have one folder which have many text file . every text file name is currant date.


推荐答案

我首先设计并创建一个合适的数据库,然后:

  • 查找文件夹中的所有输入文件(它们不能共享同一个名称,正如你的问题似乎暗示)。
I would first design and create a suitable database, then:
  • Find all the input files in the folder (they cannot share the same name, as your question seems to suggest).
  • 解析它以便全部提取所需的数据。
  • 用这些数据填充数据库表。


1)在项目中添加对Microsoft ADO Ext 6.0 for DDL and Security的引用。 (你会在COM下找到它)

2)使用ADOX 语句添加

3)创建实际数据库:

1) Add a reference to "Microsoft ADO Ext 6.0 for DDL and Security" to your project. (You'll find it under COM)
2) Add the using ADOX statement
3) Create the actual database:
Catalog cat = new Catalog();
cat.Create(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Temp\myNewAccessDB.accdb;");



4)添加表格:


4) Add tables:

Table tab = new Table();
tab.Name = "MyTable";
tab.Columns.Append("ID", DataTypeEnum.adInteger);
tab.Columns.Append("UserName", DataTypeEnum.adVarWChar, 50);
cat.Tables.Append(tab);


这篇关于从文件夹中读取文本文件,然后在vb.net中创建一个访问数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆