Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

 

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

TrialDownload2.zip

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...