将csv文件导入datagridview时,列中不正确

时间:2017-11-21 14:39:17

标签: sql excel vb.net csv datagridview

将csv文件导入datagridview时出现问题。它只在添加列中不在适当的列中。

以下是代码:

 Try
        Dim conn As System.Data.OleDb.OleDbConnection
        Dim ds As System.Data.DataSet
        Dim comm As System.Data.OleDb.OleDbDataAdapter
        Dim path As String = filepath

        conn = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + "; Extended Properties=Excel 12.0;")
        comm = New System.Data.OleDb.OleDbDataAdapter("Select * from [WSC2017_TP09_M2_Schedules_V12_a$]", conn)

        ds = New System.Data.DataSet
        comm.Fill(ds)
        DataGridView1.DataSource = ds.Tables(0)

        conn.Close()

    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

这里有一些图片......

应该在这里: it is supposed to be here; 但它在这里: but it goes here.

0 个答案:

没有答案