I am using ACE.OLEDB inside Excel to run sql and use my sheets like if they are a database. On my Pc local drive everything works perfectly, but once I upload the file to Sharepoint and launching it from there I am getting the following error :
error number : -2147467259 error description : "Cannot update. Database or object is read-only."
I checked on the net and found some people solving such problem by changing their connection string and adding like IMEX=1 to the extended properties. I tried some suggestions, but it didn't work, maybe I didn't get it well that's why I need your help. By the way, I do only a Select with my SQL (not an Insert), so I don't know why it needs more than read-only permissions (if any of you can explains it to me), and if manually I try to create a file or folder in the Sharepoint I have no problem with that, that's why I don't think it's a Sharepoint problem.
Here are the rest of parts of the code that may interest you to help me.
I prepare my sql request and call the OpenRecordset which calls the GetConnection function.
sql = "SELECT Distinct Offres FROM ['" & sMySheet & "$'] WHERE Domaine IS NOT NULL AND Domaine = '" & sTempDomaine & "';"
Set rst = OpenRecordset(sql)
The above line will call the OpenRecordset function with the sql request
Public Function OpenRecordset(sql As String) As Object
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H1
Set OpenRecordset = CreateObject("ADODB.Recordset")
OpenRecordset.Open sql, GetConnection(), adOpenStatic, adLockOptimistic, adCmdText
End Function
Then OpenRecordset will call the GetConnection and here is where I get the error
Private Function GetConnection() As Object
Dim m_Connection As Object
If m_Connection Is Nothing Then
Set m_Connection = CreateObject("ADODB.Connection")
'Error at the following line
m_Connection.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & ThisWorkbook.FullName & ";Extended Properties=""Excel 12.0;HDR=Yes;"";"
End If
Set GetConnection = m_Connection
End Function
I get the error precisely at the line of code:
m_Connection.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & ThisWorkbook.FullName & ";Extended Properties=""Excel 12.0;HDR=Yes;"";"
I hope that any of you may help me to solve this problem