T
twq
Hello
I would like to import a csv file into a dataset,
In one column i have a mix of string and numeric values, the problem
is that somehow only the numeric values are imported and all string
values are imported as null values, what i want is that all values are
imported as string values. Does anyone has an idea how to do that?
here is the code:
Function GetCVSFilePrice(ByVal pathfile As String)
Dim CSVConnection As OleDbConnection = New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
pathfile & ";Extended Properties=Text")
Dim CSVCommand As OleDbCommand = New OleDbCommand("SELECT
DISTINCT instr_code, ptf_date, today_price FROM " & pathfile ,
CSVConnection)
Dim CSVAdapter As OleDbDataAdapter = New
OleDbDataAdapter(CSVCommand)
Dim CSVDataSet As DataSet = New DataSet()
Try
CSVConnection.Open()
CSVAdapter.Fill(CSVDataSet)
CSVConnection.Close()
Catch
CSVDataSet = Nothing
End Try
Return CSVDataSet
CSVDataSet.Clear()
End Function
I would like to import a csv file into a dataset,
In one column i have a mix of string and numeric values, the problem
is that somehow only the numeric values are imported and all string
values are imported as null values, what i want is that all values are
imported as string values. Does anyone has an idea how to do that?
here is the code:
Function GetCVSFilePrice(ByVal pathfile As String)
Dim CSVConnection As OleDbConnection = New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
pathfile & ";Extended Properties=Text")
Dim CSVCommand As OleDbCommand = New OleDbCommand("SELECT
DISTINCT instr_code, ptf_date, today_price FROM " & pathfile ,
CSVConnection)
Dim CSVAdapter As OleDbDataAdapter = New
OleDbDataAdapter(CSVCommand)
Dim CSVDataSet As DataSet = New DataSet()
Try
CSVConnection.Open()
CSVAdapter.Fill(CSVDataSet)
CSVConnection.Close()
Catch
CSVDataSet = Nothing
End Try
Return CSVDataSet
CSVDataSet.Clear()
End Function