Using VBA to communicate SQL Server Compact

S

Spiros

Dear Friennds

For the purpose of testing I wrote the following code...

Sub SyncStockItems()

Dim pConn As ADODB.Connection
Dim pRs As ADODB.Recordset

Set pConn = New ADODB.Connection
Set pRs = New ADODB.Recordset

pConn.ConnectionString = "PROVIDER=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data
Source=C:\Apog\Apog.sdf"

-----'pConn.ConnectionString =
"PROVIDER=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=C:\Apog\Apog.sdf"
If pConn.State = 1 Then
pConn.Close
End If
pConn.Open

'Delete All Records from Mobile Database
pConn.Execute "DELETE * FROM StockItems"
'pRs.Open

pRs.Close
pConn.Close

Set pRs = Nothing
Set pConn = Nothing


In debugging mode when the line pConn.Open reached it produces the following
error:

"Run-time error -2147467259 (800004005)

Method "Open" of object '_Connection' failed.

Any ideas of what it may be...?

Thank you in advance...

Spiros..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top