hi
I am reading from a .CSV file and filling a dataset with the data that I return. The problem that I am encountering is that the dataset does not pick up the data from the first column if it is in a format other than int. The .CSV file is accessed and opened using Excel, would this have anything to do with the problem? The name of the column is Custom_ID, I have also attached the .CSV file.
I am reading from a .CSV file and filling a dataset with the data that I return. The problem that I am encountering is that the dataset does not pick up the data from the first column if it is in a format other than int. The .CSV file is accessed and opened using Excel, would this have anything to do with the problem? The name of the column is Custom_ID, I have also attached the .CSV file.
Code:
Public Function readFromCSV(ByVal filetable As String, ByRef data As DataSet) As Boolean
readFromCSV = True
Dim ds As New DataSet
Dim fileLocation As String
Dim sql_select As String
Dim obj_oledb_da As System.Data.Odbc.OdbcDataAdapter
Dim obj_oledb_con As New System.Data.Odbc.OdbcConnection
fileLocation = getUploadDownloadDetails() Get the location where the file is stored.
fetchData((fileLocation + filetable), filetable, data)
conn_excel_str = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" & fileLocation & ";Extensions=asc,csv,tab,txt;"
data.Dispose()
data.Clear()
Try
obj_oledb_con = New System.Data.Odbc.OdbcConnection(conn_excel_str) Creat a new connection.
obj_oledb_con.Open() Open the connection.
sql_select = "select * from [" + filetable + "]"
obj_oledb_da = New System.Data.Odbc.OdbcDataAdapter(sql_select, obj_oledb_con) Execute the statement.
obj_oledb_da.Fill(ds) Fill the dataset with the data returned.
obj_oledb_con.Close() Close the connection.
data = ds
Catch e As Exception
readFromCSV = False
End Try
End Function