G
Guest
I am trying to import a file using a custom VB.net procedure, but the problem
is it works on a file with pure comma separation and not inverted commas and
commas, i.e. it works for AAA,BBB,CCC,DDD but not for "AAA","BBB","CCC","DDD".
Here is an extract from the code which needs to be modified for the """:
Sub LoadTextFile(ByVal strFilePath As String)
Dim oDS As New DataSet()
Dim strFields As String
Dim oTable As New DataTable()
Dim oRows As DataRow
Dim intCounter As Integer = 0
Dim intI As Integer = 0
Dim strDelimiter As String = "," <----THIS IS FOR THE COMMA SEP
Dim oSR As New IO.StreamReader(strFilePath)
Dim FileID As String
Dim FileName As String
Dim DbName As String
Dim oConn As SqlClient.SqlConnection
'Try
oImportForm.Refresh()
'Create Datatable with 12 columns
oDS.Tables.Add("InputTable")
Do While intI <= 51
oDS.Tables("InputTable").Columns.Add(intI)
intI = intI + 1
Loop
'Read the text file into the data set
oTable = oDS.Tables(0)
While (oSR.Peek() > -1)
oRows = oTable.NewRow()
For Each strFields In oSR.ReadLine().Split(strDelimiter)
<----HOW DO I MOD THIS FOR "AAA","BBB" AS IT WORKS FOR AAA,BBB?
oRows(intCounter) = strFields
intCounter = intCounter + 1
Next
intCounter = 0
oTable.Rows.Add(oRows)
End While
oSR.Close()
Thanks,
SKC
is it works on a file with pure comma separation and not inverted commas and
commas, i.e. it works for AAA,BBB,CCC,DDD but not for "AAA","BBB","CCC","DDD".
Here is an extract from the code which needs to be modified for the """:
Sub LoadTextFile(ByVal strFilePath As String)
Dim oDS As New DataSet()
Dim strFields As String
Dim oTable As New DataTable()
Dim oRows As DataRow
Dim intCounter As Integer = 0
Dim intI As Integer = 0
Dim strDelimiter As String = "," <----THIS IS FOR THE COMMA SEP
Dim oSR As New IO.StreamReader(strFilePath)
Dim FileID As String
Dim FileName As String
Dim DbName As String
Dim oConn As SqlClient.SqlConnection
'Try
oImportForm.Refresh()
'Create Datatable with 12 columns
oDS.Tables.Add("InputTable")
Do While intI <= 51
oDS.Tables("InputTable").Columns.Add(intI)
intI = intI + 1
Loop
'Read the text file into the data set
oTable = oDS.Tables(0)
While (oSR.Peek() > -1)
oRows = oTable.NewRow()
For Each strFields In oSR.ReadLine().Split(strDelimiter)
<----HOW DO I MOD THIS FOR "AAA","BBB" AS IT WORKS FOR AAA,BBB?
oRows(intCounter) = strFields
intCounter = intCounter + 1
Next
intCounter = 0
oTable.Rows.Add(oRows)
End While
oSR.Close()
Thanks,
SKC