我在写一个SharePoint表时遇到问题我通过ADODB连接到了。我正在编写一个vb.net应用程序,虽然这可以在我的机器上运行,但当我编译项目并发布它时,我会在部署后继续报告以下错误。
The Microsoft Office Access database engine could not find the object 'Table_Name
adodb连接对象正在成功打开,但是当我调用CommitTrans
或.Execute
方法时,我会收到此错误。 SharePoint的版本是Office 365。
我有什么东西可以忽略吗?
代码:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Add.Click
Dim connection As ADODB.Connection = connectDb()
Dim rs As New ADODB.Recordset
Try
If Not connection Is Nothing Then
Me.TextBox1.Text = "Connected"
Me.Refresh()
Else
Me.TextBox1.Text = "Connection Failed"
End If
Dim i As Byte
Dim AppendSQL As String = "Insert Into Table ([Count], [Date], UserName, AppName, WindowTitle, URL, ProductiveTime, IdleTime ) " & _
"Values (1,#1/20/2017#,'','','','',1,1)"
rs.Open("Select top 1 * from Table", connection, 2, 3)
connection.BeginTrans()
For i = 1 To 5
With rs
.AddNew()
.Fields(0).Value = 1
.Fields(1).Value = "Example"
.Update()
End With
Next
connection.committrans()
MsgBox("Data should have been written to SharePoint")
Catch ex As Exception
MsgBox("An error occurred: " & ex.Message)
End Try
End Sub
Function connectDb() As Object
Try
Dim connection As Object = CreateObject("Adodb.connection")
Const ListID As String = "{61C6957D-37A9-440C-A79D-A85D15C95F91};"
Const ViewID As String = "{0C93F8A2-00FB-42E7-80A9-1FE82F7FAB3D};"
Const ConnectionStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;WSS;HDR=Yes;IMEX=0;RetrieveIds=Yes;" & _
"DATABASE=https://mywebsite/sites/thesiteName/;" & _
"LIST=" & ListID & _
"VIEW=" & ViewID
With connection
.connectionstring = ConnectionStr
.Mode = ADODB.ConnectModeEnum.adModeWrite
.open()
End With
connectDb = connection
Catch ex As Exception
MsgBox("An error occurred: " & ex.Message)
connectDb = Nothing
End Try
End Function
End Class
答案 0 :(得分:0)
我能够解决这个问题。事实证明我使用2007可再发行的Access引擎和我的安装程序。我注意到我在本地机器上使用2010。切换到2010年可再发行组件解决了两台机器上的问题。