conngs.Execute "INSERT into sp_old (item_no,item_name) select item_no,item_name from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0 ', 'Data Source=" & App.Path & "\spmx.mdb;User ID=Admin;Password=; ')...sp_new "请问这句为什么出现了 From 子句语法错误的提示, 实时错误 -2147217900
conngs.Execute "INSERT INTO sp_old (item_no,item_name) SELECT item_no,item_name FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', '" & App.Path & "\spmx.mdb'; 'admin'; '', CXMX) Rowset_2"按这个语句也是出现了From 子句语法错误的提示, 实时错误 -2147217900 ,不明白产生原因
conngs.Execute "INSERT INTO sp_old (item_no,item_name) SELECT item_no,item_name FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', '" & App.Path & "\spmx.mdb'; 'admin'; '', CXMX) Rowset_2"按这个语句也是出现了From 子句语法错误的提示, 实时错误 -2147217900 ,不明白产生原因
select a,b
from table1
这样的语句在SQL SERVER 2000中是可以通过的,我写的没有错吧,如加 VALUES 好象就需要有具体的值了吧
Private Sub Command1_Click()
Dim conngs As New ADODB.Connection
conngs.Open "Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=pubs;Data Source=."
conngs.Execute "INSERT INTO ta (x2, x3) SELECT a, b FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'c:\11.mdb'; 'admin'; '', tb11)"
End SubRowset_2 是别名,可以不要。
3楼提示用绝对路径并没有解决问题,反倒提示,编译错误无结束语句 光标落在f:\program\spmx.mdb 中的f:上。4楼的提示我已警觉
connrs.Execute "insert into OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" & _
"f:\Program Files\Program\VB6.0\CODE\kmjxc_plus\spmx.mdb" & _
";User ID=;PassWord=' )...bi_t_branch_info (branch_no,branch_name) " & _
"select branch_no,branch_name from bi_t_branch_info"
实时错误 、‘-2147217900 (80040e14)’
[Microsoft][ODBC SQL Server Driver][SQL Server]SQL Server 阻止了对组件 ‘Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource '的访问,因为此组件已作为此服务器安全配置的一部分而被关闭,系统管理员可以通过时候用 sp_configure 启用 'Ad Hoc Distributed Queries'.
先打开 1 开 0 关
connrs.Execute " sp_configure 'Ad Hoc Distributed Queries', 1 RECONFIGURE"再执行
connrs.Execute "insert into OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" & _
App.Path & "\spmx.mdb;User ID=;PassWord=' )...bi_t_branch_info (branch_no,branch_name) " & _
"select branch_no,branch_name from bi_t_branch_info"
‘Ad Hoc Distributed Queries' 不存在,也可能是高级选项。
我现在用的是VB6.0 +SQL2005+ACCESS 2003
connrs.Execute " sp_configure 'Ad Hoc Distributed Queries', 1 RECONFIGURE"
要用系统管理员的权限。connrs 是用 sa 用户连接的吗?要不然直接在数据库里 运行 sp_configure 'Ad Hoc Distributed Queries', 1 RECONFIGURE
connrs.Execute "sp_configure 'show advanced options',1 reconfigure"
connrs.Execute " sp_configure 'Ad Hoc Distributed Queries', 1 RECONFIGURE"
connrs.Open strrs直接执行的 sp_configure 'Ad Hoc Distributed Queries', 1 RECONFIGURE 语句,有同样的提示,难道是我安装的2005不同
connrs.Execute " sp_configure 'Ad Hoc Distributed Queries', 1 RECONFIGURE"好像是可以通过,一会在最终确认一下,执行完语句后还需要关闭么,是否执行以下两句
connrs.Execute "sp_configure 'show advanced options',0 reconfigure"
connrs.Execute " sp_configure 'Ad Hoc Distributed Queries', 0 RECONFIGURE"我的系统是 windows2008 server+SQL2005需要执行这两句,如果服务器的系统是 WINDOWS2003+SQL2000,是否还需要执行
connrs.Execute "select * from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" & _
App.Path & "\spmx.mdb;User ID=;PassWord=' )...bi_t_branch_info "
如果能执行,就不用管它了吧。sql2005 是否要关闭 自己拿主意吧
关了 就不能用 OpenDataSource
App.Path & "\spmx.mdb;User ID=;PassWord=' )...bi_t_branch_info "以上代码,俩数据库在同一台机器上可以通过,如果在不同服务器之间,如何书写代码,请教?
现在情况是:
ACCESS 在 panshi605 机器上
SQL SERVER2000 在 10.106.0.2 机器上
"\\panshi605\共享的文件夹\spmx.mdb;User ID=;PassWord=' )...bi_t_branch_info
connrs.Execute "select * from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" & _
App.Path & "\spmx.mdb;User ID=;PassWord=' )...bi_t_branch_info "