我想在局域网中互相访问对方机器的sql数据库,请问
1.在对方的机器上数据库需要设置什么?
2.我如果使用
dim cn as new adodb.connecttion
cn.open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist SecurityInfo=False;Initial Catalog=aa;Data Source=JOENEE" open中的语句有哪些错误,都代表什么意思呢??谢谢了
1.在对方的机器上数据库需要设置什么?
2.我如果使用
dim cn as new adodb.connecttion
cn.open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist SecurityInfo=False;Initial Catalog=aa;Data Source=JOENEE" open中的语句有哪些错误,都代表什么意思呢??谢谢了
dim cn as new adodb.connection
with cn
if .state = adStateOpen Then .close
.connectionstring = "driver=SQL Server;server=计算机名或IP地址;uid=sa;pwd=;database=数据库名"
.commandtimeout = 300
.open
end with
域网内SQL访问,远程的可能需要固定IP或者用VPN
2.如果你要访问的数据库使用的是Windows集成安全验证方式,那就没错误
如果要访问的数据库使用的是指定用户名和密码的登陆方式,那么连接字符串就要改一下:
cn.open "Provider=SQLOLEDB.1;Persist SecurityInfo=False;ID=sa;Password=123;Initial Catalog=aa;Data Source=JOENEE"
Provider=SQLOLEDB.1指出连接的是SQL Server,Persist
SecurityInfo=False指出的登录方式
ID是登录用户名,Password是登陆密码
Initial Catalog=aa是要访问的数据库aa
Data Source=JOENEE是sql服务器别名 如果访问的是远程的服务器,还要指出服务器的ID:Server=IP地址
学习,没连接过远程的!!!^-^
我用
cn.open "Provider=SQLOLEDB.1;Persist SecurityInfo=False;ID=sa;Password=123;Initial Catalog=aa;Data Source=JOENEE"
打不开对方的数据库,但使用
cn.open "dsn=aa" '我没有在odbc中建立数据源
却可以自动检测到对方的数据库,并进行操作.为什么呀??