从记事本中读取数据并存储在ms-access中 [英] reading data from notepad and storing in ms-access

查看:78
本文介绍了从记事本中读取数据并存储在ms-access中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名学生,我将创建一个具有ms访问权限的窗口应用程序,该应用程序将从记事本文件中读取数据并将其存储在数据库中.

记事本文件的特定格式为:

名称|年龄

如果我的读者在"|"之后找到名称",则下一个数据应转到年龄"部分.
我期待一些技巧或某种编码帮助,以便可以进行我的应用程序.

问候,
[已删除电子邮件]

[edit]除非您真的喜欢垃圾邮件,否则请不要在任何论坛中发布您的电子邮件地址!如果有人回复您,您将收到一封电子邮件通知您. -OriginalGriff [/edit]

I am a student and I am going to create a window application with ms access that will read data from a notepad file and and store it in the database.

Notepad file will be in specific foramt as:

name|age

If my reader finds ''name'' and there after a ''|'' then next data should go to age section.
I am expecting some tips or kind of coding help so that I can make my application.

Regards,
[EMAIL DELETED]

[edit]Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know. - OriginalGriff[/edit]

推荐答案

最简单的方法是使用ReadAllLines方法读取文件:
The easiest way is to read the file in using the ReadAllLines method:
string[] lines = File.ReadAllLines(path);

然后可以分别处理每行:

You can then process each line individually:

foreach (string line in lines)

并将每一行分成两部分:

And process each line into two sections:

string[] sections = line.Split(''|'');

检查您是否有两部分(或存在输入问题),然后使用它们:

Check you have two sections (or there is an input problem), and then use them:

string name = sections[0];
string age = sections[1];

然后要做的就是将它们保存到数据库中. br/>
注意:您几乎在那里拥有了所需的所有代码:在确定如何全部融合"方面,我还剩下一些工作要做.因为这是您的家庭作业,所以做一些工作是公平的! :laugh:

All you have to do then is save them to your database.

Note: You have nearly all the code you need there: I have left you some work in deciding how to "bolt it all together". Since it is your homework, it is only fair you do some of the work! :laugh:


这篇关于从记事本中读取数据并存储在ms-access中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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