[quoted text, click to view] On Mon, 20 Jun 2005 07:07:38 -0700, Kerr <kerr_rk@lycos.co.uk> wrote:
¤
¤ 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
~~~~