Ado connection to SQL Server Compact Edition 4.0

前端 未结 2 1739
误落风尘
误落风尘 2020-12-19 19:59

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

相关标签:
2条回答
  • 2020-12-19 20:36

    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" 
    
    0 讨论(0)
  • 2020-12-19 20:45

    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.

    0 讨论(0)
提交回复
热议问题