Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Path.GetDirectoryName(CSVName) & "\;Extended Properties=""text;HDR=YES;FMT=Delimited"""
Dim objConn As New System.Data.OleDb.OleDbConnection(sConnectionString)
Dim da As OleDb.OleDbDataAdapter
'Open Data Adapter to Read from Text file
Dim str As String = "SELECT * FROM [" & Path.GetFileName(CSVName) & "]"
da = New System.Data.OleDb.OleDbDataAdapter(str, objConn)
'Fill dataset using dataadapter
da.FillSchema(SystemTable, SchemaType.Mapped)
For Each column As DataColumn In SystemTable.Columns
If column.ColumnName = "WINDIV" Then column.DataType = System.Type.GetType("System.String")
If column.ColumnName = "PLCDIV" Then column.DataType = System.Type.GetType("System.String")
If column.ColumnName = "SPDIV" Then column.DataType = System.Type.GetType("System.String")
Next
da.Fill(SystemTable)
objConn.Close()
|