导入文本文件 [英] importing a text file

查看:80
本文介绍了导入文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有


什么是采用逗号分隔的文本文件并通过oledb提供者将其插入数据库的最佳方式


提前感谢

rodchar

hey all

what''s the best way to take comma-delimited text file and insert it into a database via oledb provider

thanks in advance
rodchar

推荐答案

查看文字提供者..有一个特定的CSV连接字符串

和OleDb http: //www.connectionstrings.com


您可以直接将其用作数据源并使用dataAdapter.Fill(dataSet,

" datatableName" ;);


现在,您需要另一个适配器来获取这些数据并将其输入您的数据库

但这很容易并且就像配置任何其他适配器一样。


你唯一需要做的就是将.AcceptChangesDuringFill属性

设置为false,这样每个的rowstate将添加行代替

不变.. http://www.knowdotnet.com/articles/datasetmerge.html


然后只需调用DataAdapter2.Update(dataSet," datatableName");


所以你有一个适配器填写它,一个提交更新,并确保

您在使用的适配器上将AcceptChangesDuringFill属性设置为false

来填充数据集。


HTH,


比尔


-

WG Ryan MVP Windows - 嵌入式

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/

" rodchar" <一个******* @ discussions.microsoft.com>在留言中写道

新闻:BC ********************************** @ microsof t.com ...
Check out the "Text" provider.. there''s a specific connection string for CSV
and OleDb http://www.connectionstrings.com

You can use it directly as a datasource and use dataAdapter.Fill(dataSet,
"datatableName");

Now, you''ll need another adapter to take this data and get it into your DB
but that''s pretty easy to do and just like configuring any other adapter.

The only thing you need to do is set the .AcceptChangesDuringFill property
to false so that the rowstate of each of the rows will be Added instead of
unchanged.. http://www.knowdotnet.com/articles/datasetmerge.html

Then just call DataAdapter2.Update(dataSet, "datatableName");

So you have one adapter to fill it, one to submit the updates, and make sure
you set the AcceptChangesDuringFill property to false on the adapter you use
to Fill the dataset with.

HTH,

Bill

--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
"rodchar" <an*******@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
嘿所有,

采用逗号分隔的文本文件并将其插入
数据库的最佳方法是什么? oledb提供者?
提前感谢,
rodchar
hey all,

what''s the best way to take comma-delimited text file and insert it into a database via oledb provider?
thanks in advance,
rodchar



2004年5月28日星期五09:21:06 -0700, ; rodchar" <一个******* @ discussions.microsoft.com>写道:

$ b $b¤如果它的标签/空格分隔,我的字符串怎么样?


对于制表符和空格分隔的文件你需要创建一个schema.ini文件:

http://msdn.microsoft.com/library/de...a_ini_file.asp


以下是几个例子。


空格分隔:


[Order.txt]

ColNameHeader = False

格式=分隔()

CharacterSet = ANSI


制表符分隔:


[TabDelimitedFile.txt]

ColNameHeader = False

格式= TabDelimited

CharacterSet = ANSI

Paul ~~~ pc******@ameritech.net

Microsoft MVP(Visual基本)
On Fri, 28 May 2004 09:21:06 -0700, "rodchar" <an*******@discussions.microsoft.com> wrote:

¤ What if it''s tab/space delimited, how would my string look?

For tab and space delimited files you need to create a schema.ini file:

http://msdn.microsoft.com/library/de...a_ini_file.asp

Below are a couple of examples.

Space delimited:

[Order.txt]
ColNameHeader=False
Format=Delimited( )
CharacterSet=ANSI

Tab delimited:

[TabDelimitedFile.txt]
ColNameHeader=False
Format=TabDelimited
CharacterSet=ANSI
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)


让我们说它是一个逗号分隔的文件,那么数据广告怎么样apter定义。 SQL字符串是什么样的?例如Select * from authors,from子句后的值对于文本文件是什么


rodchar
Let''s say it''s a comma delimited file, what about the data adapter definition. What would the SQL string look like? For instance "Select * from authors", what would the value after the from clause be for a text file

rodchar


这篇关于导入文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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