M
Mika M
I'm retrieving CSV-file like this way...
Dim strFilePath As String = MyCSVSourceFilePath
Dim strConnStr As String = String.Format( _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended
Properties=Text;", _
Path.GetDirectoryName(strFilePath))
Dim strSQL As String = String.Format("SELECT * FROM {0}",
Path.GetFileName(strFilePath))
Dim da As OleDbDataAdapter = New OleDbDataAdapter(strSQL, strConnStr)
Dim dt As DataTable = New DataTable
da.Fill(dt)
....rest of code continues here...
....and it's working fine, but is it possible to use with this sql-query
something like "WHERE MyFirstField LIKE 'ABC%'" when csv-file has no
column names as first line, only data rows?
Propably not. This would make it easier to get only those data rows I
really need, and avoid to check each row separately like...
For Each dr As DataRow In dt.Rows
If (dr(0).ToString.StartsWith("ABC")) Then
'... doing something here...
End If
Next
....not much code lines saved, but good to know!
Dim strFilePath As String = MyCSVSourceFilePath
Dim strConnStr As String = String.Format( _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended
Properties=Text;", _
Path.GetDirectoryName(strFilePath))
Dim strSQL As String = String.Format("SELECT * FROM {0}",
Path.GetFileName(strFilePath))
Dim da As OleDbDataAdapter = New OleDbDataAdapter(strSQL, strConnStr)
Dim dt As DataTable = New DataTable
da.Fill(dt)
....rest of code continues here...
....and it's working fine, but is it possible to use with this sql-query
something like "WHERE MyFirstField LIKE 'ABC%'" when csv-file has no
column names as first line, only data rows?
Propably not. This would make it easier to get only those data rows I
really need, and avoid to check each row separately like...
For Each dr As DataRow In dt.Rows
If (dr(0).ToString.StartsWith("ABC")) Then
'... doing something here...
End If
Next
....not much code lines saved, but good to know!