请问,.net如何将csv文件直接读入dataSet

ccec   2007-2-6 16:44 楼主
wince下没有odbc包,以下代码无法运行
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim strConn As String
        Dim strSql As String = "select * from" + " 1.csv"
        Dim objConn As OdbcConnection
        Dim dataSet As DataSet = New DataSet
        Dim dataRow As DataRow
        Dim odbcCSVDataAdapter As New OdbcDataAdapter

        dataSet.Tables.Add(New DataTable())
        strConn = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq="
        strConn += "e:\"
        strConn += ";Extensions=asc,csv,tab,txt;"
        objConn = New OdbcConnection(strConn)
        odbcCSVDataAdapter = New OdbcDataAdapter(strSql, objConn)
        odbcCSVDataAdapter.Fill(dataSet.Tables(0))
    End Sub

回复评论

暂无评论,赶紧抢沙发吧
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复