我導入從Excel數據文件的datagridview在Visual Studio 有提示作爲
錯誤無法更新數據庫或對象
只讀
當我執行程序。到目前爲止,我已經做了
- 安裝ACCESSDATABASE ENGINE
- 臺階設置的TO VS設置對於x86平臺上的應用CONFIG.MANAGER
- 授予當前用戶的所有要求的權限使用鼠標右鍵和EXCEL的性能文件 有沒有其他方法可以解決這個問題?
Public Class ExcelData
Private Sub ExcelData_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim dataSet As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
Dim path As String = "& TextBox2.text &"
MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;")
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection)
dataSet = New System.Data.DataSet
MyCommand.Fill(dataSet)
DataGridView1.DataSource = dataSet.Tables(0)
MyConnection.Close()
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
End Class
顯示一些代碼和您遇到問題的位置。 –
我給出了屏幕截圖 – Sachin