Ado 连接到 SQL Server Compact Edition 4.0 [英] Ado connection to SQL Server Compact Edition 4.0

查看:33
本文介绍了Ado 连接到 SQL Server Compact Edition 4.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从旧的 asp-classic 站点连接到 SQL Server Compact Edition 4.0,但我总是收到错误:

I want to connect to SQL Server Compact Edition 4.0 from an old asp-classic site but i always get the error:

用于 ODBC 驱动程序的 Microsoft OLE DB 提供程序错误 '80004005'[Microsoft][ODBC Driver Manager] 未找到数据源名称且未指定默认驱动程序."

我试过了

sCon = "Data Source=c:	empsqlcompact.sdf;Encrypt Database=True;Password=testtest;Persist Security Info=False;"

更新:错误:多步 OLE DB 操作产生错误.检查每个 OLE DB 状态值(如果可用).没有完成任何工作

Update: Error: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done

sCon = "Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;Data Source=c:	empsqlcompact.sdf;Password=testtest;"

没有任何成功.

通常是否可以从 ADO 连接到 SQL Server CE 4.0?

Is it generally possible to connect to SQL Server CE 4.0 from ADO?

更新:示例代码打开连接:

Update: Example Code Open Connection:

dim sCon

dim gCON : set gCON=CreateObject ("ADODB.Connection")

sCon = "Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;Data Source=c:	empsqlcompact.sdf;Pwd=testtest;"

gCon.ConnectionString = sCon
gCon.Open 
gCon.Close

推荐答案

是的,您可以通过 ADO 连接到 SQL CE 4.

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:
w40.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:
w40.sdf;ssce:database password=secret" 

这篇关于Ado 连接到 SQL Server Compact Edition 4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆