大家新年好!請教一個問題.
我用ASP.NET連接另一台電腦上的ACCESS數據庫,但是運行到 Me.OleDbConnection1.Open()時就打不開,我的代碼是
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在這裡放置使用者程式碼以初始化網頁
Try
If Not Page.IsPostBack Then
Me.OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\192.168.8.29\mrp_programs\Test_Data\PartList\PartList_S.mdb "
Me.OleDbConnection1.Open()
Me.OleDbDataAdapter1.Fill(Me.DataSet11)
Me.DataGrid1.DataSource = Me.DataSet11.Tables(0)
Me.DataGrid1.DataBind()
End If
Finally
Me.OleDbConnection1.Close()
End Try
End Sub
提示為:{Microsoft Jet 資料庫引擎無法開啟 '\\192.168.8.29\mrp_programs\Test_Data\PartList\PartList_S.mdb ' 檔案。它已經被其他的使用者獨佔地開啟,或者您需要有檢視資料的權限。}
若將數據庫PartList_S.mdb拷到本機c盤或e盤連接的,就可以打開.數據庫PartList_S.mdb拷到本機c盤,然后代碼改為:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在這裡放置使用者程式碼以初始化網頁
Try
If Not Page.IsPostBack Then
Me.OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\PartList_S.mdb "
Me.OleDbConnection1.Open()
Me.OleDbDataAdapter1.Fill(Me.DataSet11)
Me.DataGrid1.DataSource = Me.DataSet11.Tables(0)
Me.DataGrid1.DataBind()
End If
Finally
Me.OleDbConnection1.Close()
End Try