Quantcast
Viewing all articles
Browse latest Browse all 15795

VS 2017 Importing CSV Strings as numbers

Hello, I'm having trouble reading in certain CSV's. When I have an alphanumeric field, It's been read in as a number. Anyone know why and how to fix?

Code:

            DialogName = IO.Path.GetFileNameWithoutExtension(DialogFile)
            Dim DialogFileName As String = IO.Path.GetFileName(DialogFile)
            Dim Page As TabPage = New TabPage() With {.Text = DialogName, .Name = $"{DialogName}"}
            Dim dgv As New DataGridView
            Dim txtData As DataTable = New DataTable()
            'Dim txtCon As OleDb.OleDbConnection = New OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & DialogDirect & "';Extended Properties='Text;HDR=Yes;FMT=Delimited(,)'")
            Dim txtCon As OleDb.OleDbConnection = New OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & DialogDirect & "';Extended Properties='Text;HDR=Yes;FMT=Delimited'")
            Dim txtCmd As OleDb.OleDbCommand = New OleDb.OleDbCommand("SELECT * FROM [" & DialogFileName & "]", txtCon)
            Dim txtAdapt As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(txtCmd)
            txtAdapt.Fill(txtData)
            txtCon.Close()
            With dgv
                .Name = $"dgv{DialogName}"
                .Parent = Page
                .Dock = DockStyle.Fill
                .DataSource = txtData
                .AllowUserToAddRows = False
                .AllowUserToOrderColumns = False
            End With
            txtData.Dispose()
            Page.Controls.Add(dgv)
            BulkTabControl.TabPages.Add(Page)
            AddHandler dgv.MouseUp, AddressOf BulkGrid_MouseUp
            AddHandler dgv.UserDeletingRow, AddressOf BulkGrid_UserDeletingRow

The above code is used to read in the this sample csv
Image may be NSFW.
Clik here to view.
Name:  csv.PNG
Views: 36
Size:  4.5 KB


However the result I get in the DGV is as follows;
Image may be NSFW.
Clik here to view.
Name:  dgv result.jpg
Views: 34
Size:  7.3 KB


Thank You
Attached Images
Image may be NSFW.
Clik here to view.
 Image may be NSFW.
Clik here to view.
 

Viewing all articles
Browse latest Browse all 15795