佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 807|回复: 1

connection string的一个小疑问

[复制链接]
发表于 31-5-2006 03:50 PM | 显示全部楼层 |阅读模式
ConnectionString: "provider=Microsoft.Jet.OLEDB.4.0; data source='C:\Documents and Settings\Administrator\My Documents\NAME LIST 1G.xls '; Extended Properties=Excel 8.0;"

以上的connectionString 可以让我fetch data from Excel file.. 那么如果我要fetch data from csv file该如何修改呢?

我进去ODBC data source administrator有看到 microsoft text driver is support (*.txt) & (*.csv), 但就是不懂该如何修改我现有的coding...


the following is my complete source code for fetch data from excel file and display to datagrid...

Public Function ImportAttendence(ByVal PrmPathExcelFile As String, ByVal DataGrid1 As DataGrid)

   Dim MyConnection As System.Data.OleDb.OleDbConnection

   Try

   ' Fetch Data from Excel

    Dim DtSet As System.Data.DataSet
    Dim MyCommand As System.Data.OleDb.OleDbDataAdapter

    MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source='" & PrmPathExcelFile & " '; " & "Extended Properties=Excel 8.0;")

     ' Select the data from Sheet1 of the workbook.

     MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [sheet1$]", MyConnection)


     MyCommand.TableMappings.Add("Table", "Attendence")

     DtSet = New System.Data.DataSet

     MyCommand.Fill(DtSet)

     DataGrid1.DataSource = DtSet.Tables(0)
     MyConnection.Close()

     Catch ex As Exception
           MyConnection.Close()
     End Try

End Function


[ 本帖最后由 counterking 于 31-5-2006 03:52 PM 编辑 ]
回复

使用道具 举报


ADVERTISEMENT

发表于 31-5-2006 09:39 PM | 显示全部楼层
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 11-11-2024 11:15 PM , Processed in 0.097538 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表