MS Access和VB.NET [英] MS Access and VB.NET

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

问题描述

我正在尝试在vb.net windows应用程序中自动执行该过程

将文本文件导入访问数据库(设置列

分隔符,第一行是列名等)但我没有在网上找到这个例子吗?有没有人碰过这样的事情?

解决方案

*" scorpion53061" < SC ************ @ nospamhereeveryahoo.com> scripsit:

我试图在vb.net windows应用程序中自动执行将文本文件导入访问数据库的过程(设置列
分隔符,第一行是列名等)但我没有在网上找到这个例子吗?有没有人碰过这样的事情?




你看过< URL:http://www.connectionstrings.com/>?


-

Herfried K. Wagner [MVP]

< URL:http://dotnet.mvps.org/>


这对将文本文件导入MS Access有何帮助?我是什么?b $ b试图做的是编写一个复制MS Access导入向导的动作
我们在想要导入文本文件时使用的



" Herfried K. Wagner [MVP]" <喜*************** @ gmx.at>在消息中写道

news:c6 ************ @ ID-208219.news.uni-berlin.de ...

* " scorpion53061" < SC ************ @ nospamhereeveryahoo.com> scripsit:

我试图在vb.net windows
应用程序中自动执行将文本文件导入访问数据库的过程(设置列
分隔符,第一行是列名等)但我没有在网上找到这个例子吗?有没有人碰过这样的事情?



你有没看过< URL:http://www.connectionstrings.com/>?
-
Herfried K. Wagner [MVP]
< URL:http://dotnet.mvps.org/>



嗨蝎子,

你可能有一个要导入数据库的CSV文件。这是一个

示例如何从CSV文件中填充数据表。它将帮助您入门


Private Sub ConnectToText_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)

处理ConnectToText.Click


''建立与数据源的连接。

Dim sConnectionString As String


sConnectionString =" Provider = Microsoft.Jet.OLEDB.4.0;" &安培; _

数据源= d:\我的文件\ TextFiles;扩展

属性=文字;"

Dim objConn As新的

System.Data.OleDb.OleDbConnection(sConnectionStrin g)

objConn.Open()


Dim da As New System .Data.OleDb.OleDbDataAdapter(Select * from

People.txt,objConn)


Dim ds As New DataSet(PeopleFile)


da.Fill(ds," People.txt")

Dim dt As DataTable

dt = ds.Tables(" People.txt")

Dim drCurrent As DataRow

For each drCurrent in dt.Rows

Console.WriteLine(" {0} {1}",_

drCurrent(" 0")。ToString,_

drCurrent(" 1" ).ToString)

下一页


objConn.Close()


End Sub


" scorpion53061" < SC ************ @ nospamhereeveryahoo.com>写在消息

新闻:你#************** @ TK2MSFTNGP12.phx.gbl ...

这是如何帮助的将文本文件导入MS Access?我想要做的是编写一个动作,复制MS Access导入向导
当我们想要导入文本文件时我们使用它?

< Herfried K 。瓦格纳[MVP]" <喜*************** @ gmx.at>在消息中写道
新闻:c6 ************ @ ID-208219.news.uni-berlin.de ...

*" scorpion53061" < SC ************ @ nospamhereeveryahoo.com> scripsit:

我试图在vb.net windows应用程序中自动执行将文本文件导入访问数据库的过程(设置列
分隔符,第一行是列名等等)但我不是
在网上找到这个例子吗?有没有人碰过这样的事情?



你有没看过< URL:http://www.connectionstrings.com/>?
-
Herfried K. Wagner [MVP]
< URL:http://dotnet.mvps.org/>




I am attempting to automate the process within a vb.net windows application
of importing a text file into an access database (setting the column
seperators, first row being column names and such) but I am not finding
examples of this on the net? Has anyone ran across such a thing?

解决方案

* "scorpion53061" <sc************@nospamhereeveryahoo.com> scripsit:

I am attempting to automate the process within a vb.net windows application
of importing a text file into an access database (setting the column
seperators, first row being column names and such) but I am not finding
examples of this on the net? Has anyone ran across such a thing?



Did you have a look at <URL:http://www.connectionstrings.com/>?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


How does this help with importing text files into MS Access? What I am
trying to do is code an action that duplicates the MS Access Import Wizard
we use when we want to import a text file into access?

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c6************@ID-208219.news.uni-berlin.de...

* "scorpion53061" <sc************@nospamhereeveryahoo.com> scripsit:

I am attempting to automate the process within a vb.net windows application of importing a text file into an access database (setting the column
seperators, first row being column names and such) but I am not finding
examples of this on the net? Has anyone ran across such a thing?



Did you have a look at <URL:http://www.connectionstrings.com/>?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>



Hi scorpion,
You probably have a CSV file that you want to import to Database. Here is an
example how to fill datatable from CSV file. It will get you started

Private Sub ConnectToText_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Handles ConnectToText.Click

''Establish a connection to the data source.
Dim sConnectionString As String

sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=d:\My Documents\TextFiles;Extended
Properties=Text;"
Dim objConn As New
System.Data.OleDb.OleDbConnection(sConnectionStrin g)
objConn.Open()

Dim da As New System.Data.OleDb.OleDbDataAdapter("Select * from
People.txt", objConn)

Dim ds As New DataSet("PeopleFile")

da.Fill(ds, "People.txt")

Dim dt As DataTable
dt = ds.Tables("People.txt")

Dim drCurrent As DataRow
For Each drCurrent In dt.Rows
Console.WriteLine("{0} {1}", _
drCurrent("0").ToString, _
drCurrent("1").ToString)
Next

objConn.Close()

End Sub

"scorpion53061" <sc************@nospamhereeveryahoo.com> wrote in message
news:u#**************@TK2MSFTNGP12.phx.gbl...

How does this help with importing text files into MS Access? What I am
trying to do is code an action that duplicates the MS Access Import Wizard
we use when we want to import a text file into access?

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c6************@ID-208219.news.uni-berlin.de...

* "scorpion53061" <sc************@nospamhereeveryahoo.com> scripsit:

I am attempting to automate the process within a vb.net windows application of importing a text file into an access database (setting the column
seperators, first row being column names and such) but I am not finding examples of this on the net? Has anyone ran across such a thing?



Did you have a look at <URL:http://www.connectionstrings.com/>?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>




这篇关于MS Access和VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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