ADODB 找不到 SharePoint Table
ADODB Cannot Find SharePoint Table
我在写入 SharePoint 时遇到问题 table 我通过 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
我能够解决这个问题。事实证明,我在安装程序中使用的是 2007 可再发行的 Access 引擎。我注意到我在本地机器上使用的是 2010。切换到 2010 可再发行版本解决了两台机器上的问题。
我在写入 SharePoint 时遇到问题 table 我通过 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
我能够解决这个问题。事实证明,我在安装程序中使用的是 2007 可再发行的 Access 引擎。我注意到我在本地机器上使用的是 2010。切换到 2010 可再发行版本解决了两台机器上的问题。