Hi,
Have a .CSV file, and I am basically doing a select all on the file to retrieve all the data. The file has a total of twelve rows, however when I do a Rows.count on the dataset I get a total of 23. The .CSV file is accessed using Microsoft Excel.
The code that I am using to access the .CSV file is a follows:
Any suggestions on why such a problem is occuring of what am I doing wrong.
Mike55
Have a .CSV file, and I am basically doing a select all on the file to retrieve all the data. The file has a total of twelve rows, however when I do a Rows.count on the dataset I get a total of 23. The .CSV file is accessed using Microsoft Excel.
The code that I am using to access the .CSV file is a follows:
Code:
Read the data stored in the .CSV file into a dataset.
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_con As System.Data.Odbc.OdbcConnection
Dim obj_oledb_da As System.Data.Odbc.OdbcDataAdapter
fileLocation = getUploadDownloadDetails() Get the location where the file is stored.
conn_excel_str = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + fileLocation Connection string.
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
Any suggestions on why such a problem is occuring of what am I doing wrong.
Mike55