主题:在本机上访问远程机上的数据库
条件:1)远程机的IP地址:192.168.10.95
2)远程机名称:peng
3)远程机上的数据库:C:\inetpub\wwwroot\WGYS.mdb
问题:自编代码如下,确无法连接。不知何错,请各位大侠指教。
Dim conn As New ADODB.Connection '定义主连接
Dim mydata As String
Set conn = New ADODB.Connection
mydata = "User ID=192.168.10.95;Data Source=PENG;" & _
"Initial Catalog=C:\inetpub\wwwroot\WGYS.mdb"
conn.Provider = "microsoft.jet.oledb.4.0"
conn.Open mydata
mdb?
数据库是:Access??
Access是不支持远程连接的,
如果一定要用,可以同过Web Service 来做
这个不可以用绝对路径,应该用Server.Mappath来获取物理路径
‘1.
set dbconnection=Server.CREATEOBJECT("ADODB.CONNECTION")
DBPath = Server.MapPath("WGYS.mdb")
dbconnection.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
SQL="select * from auth where id="" & user_id &"""
SET uplist=dbconnection.EXECUTE(SQL)
‘2.
set dbconnection=Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("WGYS.mdb")
dbconnection.Open "provider=microsoft.jet.oledb.4.0;data source="&dbpath
SQL="select * from auth where id="" & user_id &"""
SET uplist=dbconnection.EXECUTE(SQL)
’3.
DBPath = Server.MapPath("WGYS.mdb")
set session("rs")=Server.CreateObject("ADODB.Recordset")
" rs=Server.CreateObject("ADODB.Recordset")
connstr="provider=microsoft.jet.oledb.4.0;data source="&dbpath
SQL="select * from auth where id="" & user_id &"""
session("rs").Open sql,connstr,1,3
已经短消息回复你了