我有以下代码:
Imports System.Data.OleDb
Private Sub getData()
Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:rawData.xlsx;Extended Properties=Excel 12.0 Xml;"
Dim oleConn As New OleDbConnection(connStr)
Dim query As String = "SELECT * FROM [Sheet1$]"
Dim cmd As New OleDbCommand(query, oleConn)
Dim reader As OleDbDataReader
oleConn.Open() ' Getting Exception Here !!
reader = cmd.ExecuteReader()
Do While reader.Read()
InputOutput.print(reader.GetString(0)) ' Prints the 1st column.
Loop
reader.Close()
oleConn.Close()
End Sub
异常提示:can not find installable ISAM.
我做错了什么?
请帮忙,我是新手
将连接字符串更改为:
Dim connStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:rawData.xlsx;Extended Properties=""Excel 12.0 XML;"""
它就像一个魅力…div !
检查这段代码,它运行良好。
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;data source =D:ODD_2015Counselling.xlsx;extended properties=excel 12.0;"
cn.Open()