I want to connect to SQL Server Compact Edition 4.0 from an old asp-classic site but i always get the error:
\"Microsoft OLE DB Provider for ODBC Drivers error
Yes, you can connect to SQL CE 4 via ADO.
Set Cnxn = CreateObject("ADODB.Connection")
Set cmd = CreateObject("ADODB.Command")
strCnxn = "Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;" & _
"Data Source=C:\nw40.sdf;"
Cnxn.Open strCnxn
cmd.ActiveConnection = Cnxn
cmd.CommandText = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES"
While Not pRS.EOF
WScript.Echo pRS(0)
pRS.MoveNext
wend
For password protected files, use:
strCnxn = "Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;" &
_ "Data Source=C:\nw40.sdf;ssce:database password=secret"
Try with the the following provider instead, saw somewhere it's being used with success:
sCon = "Provider=Microsoft.SqlServer.Mobile.OleDb.3.0;Data Source=c:\temp\sqlcompact.sdf;Password=testtest;"
If no luck, can you create System DSN successfully? If so, create one then use it in the ASP code.