Groups | Blog | Home
all groups > vb.net data > june 2005 >

vb.net data : Files, Datasets And Databases


Kerr
6/20/2005 7:07:38 AM

Hi all,
I am sure this has been done before but I just don't know the right way
to do it.

I have a collection of CSV files in a directory on our network. I need
a method of getting the files into a SQL Server database.

Now I can import the contents of the files into a XNK Document But once
generated how do I get it into a database.

IF using a dataset is not the right method to use please tell me what
you think is a better (easier) way of getting this data into a database.

Cheers in advance.


Paul Clement
6/20/2005 11:40:01 AM
[quoted text, click to view]

¤
¤ Hi all,
¤ I am sure this has been done before but I just don't know the right way
¤ to do it.
¤
¤ I have a collection of CSV files in a directory on our network. I need
¤ a method of getting the files into a SQL Server database.
¤
¤ Now I can import the contents of the files into a XNK Document But once
¤ generated how do I get it into a database.
¤
¤ IF using a dataset is not the right method to use please tell me what
¤ you think is a better (easier) way of getting this data into a database.
¤

You could probably just import the files directly to SQL Server:

Function ImportTextToSQLServer() As Boolean

Dim TextConnection As New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "E:\My
Documents\TextFiles" & ";" & _
"Extended
Properties=""Text;HDR=NO;""")

TextConnection.Open()

'New table
Dim TextCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO [ReportSheet] IN ''
[ODBC;Driver={SQL Server};Server=(local);Database=Northwind;Trusted_Connection=yes] FROM
[ReportSheet#csv]", TextConnection)

TextCommand.ExecuteNonQuery()
TextConnection.Close()

End Function


Paul
~~~~
AddThis Social Bookmark Button