2011-07-28 225 views
1

我有以下代碼:OleDB異常:無法找到可安裝的ISAM異常,出了什麼問題?

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-找不到可安裝ISAM。

我在做什麼錯?

請幫忙,我是新手!

回答

1

改變了我的連接字符串:

Dim connStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\rawData.xlsx;Extended Properties=""Excel 12.0 XML;""" 

和它的工作就像一個魅力..!

0

請檢查此代碼,其工作正常。

cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;data source =D:\ODD_2015\Counselling.xlsx;extended properties=excel 12.0;" 
cn.Open()