将数据表内容导入CSV或TXT文件/从CSV或TXT文件导出 [英] Import / Export data table contents to / from a CSV or TXT file

查看:88
本文介绍了将数据表内容导入CSV或TXT文件/从CSV或TXT文件导出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,新手都在这里,在VB和这个论坛中.

我开始学习VB领域.我对HTML/PHP/MySQL代码有一定的了解,因此我发现VB更容易学习.

话虽如此,请把我当成新手. :)

我的问题是标题所指出的:我需要对如何创建代码片段有一个指导.

我希望我的用户单击按钮或菜单项,并能够导入/导出表中的数据以用于备份. Í没有要显示的代码,因为我什至不知道从哪里开始.不要求您去做我的工作,只是一个例子或一个正确的方向就可以了,因为我一直在Google上寻找两天,我开始感到沮丧.

将所有内容都包含在这个小项目中,并且没有API或第三方工具,那就太好了,这样我就可以真正了解自己在做什么.

这是一个可能无济于事的项目,我只是想学习.再说一遍,这可能是我有一些想法的基础...

谢谢!

Hello all, Newbie all around here, in VB as well as this forum.

I am starting to learn the realms of VB. Having intermediate knowledge on HTML/PHP/MySQL code, I find VB to be easier to learn.

With that said, please treat me as a newbie. :)

My question is as the title states: I need to have a direction on how to create a snippet of code.

I would like for my users to click on a button or menu entry and be able to import/export the data in a table, for backup purposes. Í have no code to show as I don''t even know where to begin. Not asking for you to do my work, just an example or a point to the right direction will do, as I have been looking for 2 days all over Google and I am starting to get frustrated.

It would be super nice to have it all contained inside the little project, and no API or third party tools, so I can actually learn what I am doing.

This is a project that may be going nowhere, I am just trying to learn. Then again, could be the basis for a few ideas I have...

Thanks!

推荐答案

我希望您根本不会使用该控件.您的数据表通常是根据数据源(例如数据集)构建的.结果,我认为数据表只是数据的视图,并直接与数据一起创建所需的文件. File类具有诸如WriteAllText和WriteAllLines之类的静态方法,因此我将遍历数据源,创建一个字符串数组(我可能会使用List类并在末尾调用ToArray),然后调用一种方法来保存数据.
I would expect that you would not work with the control at all. Your data table will be built typically from a data source, such as a dataset. As a result, I would consider the data table to only be a view to the data, and work with the data directly to create the file you want. The File class has static methods like WriteAllText and WriteAllLines, so I would iterate over the data source, create a string array ( I''d probably use the List class and call ToArray at the end ), then call a method to save the data.


这篇关于将数据表内容导入CSV或TXT文件/从CSV或TXT文件导出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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