SQLServer身份验证管理子程序

发表于:2007-06-21来源:作者:点击数: 标签:
下一页 1 2 3 4 5 Option Compare Database Public appAccess As Access.Application Sub CallSQLDMO SQLServer Login() Dim srvname As String Dim suid As String Dim pwd As String ' 设置 SQL Server 的登录参数 srvname = "(local)" 'suid = "sa" 'pwd

下一页 1 2 3 4 5 

   

Option Compare Database
Public appAclearcase/" target="_blank" >ccess As Access.Application

Sub CallSQLDMOSQLServerLogin()
Dim srvname As String
Dim suid As String
Dim pwd As String
' 设置 SQL Server 的登录参数
srvname = "(local)"
'suid = "sa"
'pwd = ""
' 调用 SQL Server 登录过程
SQLDMOSQLServerLogin srvname, suid, pwd
End Sub

Sub SQLDMOSQLServerLogin(srvname As String, suid As String, pwd As String)
Dim srv1 As SQLDMO.SQLServer
' 新建一个服务器实例
Set srv1 = New SQLDMO.SQLServer
' 调用 SQL Server 登录连接方法
srv1.Connect srvname, suid, pwd
' 断开连接
srv1.Disconnect
Set srv1 = Nothing
End Sub

Sub CallSQLDMOWindowsLogin()
Dim srvname As String
' 设置 Windows 登录参数
srvname = "(local)"
SQLDMOWindowsLogin srvname
End Sub

Sub SQLDMOWindowsLogin(srvname As String)
Dim srv1 As SQLDMO.SQLServer
' 新建一个服务器实例
Set srv1 = New SQLDMO.SQLServer
' 在调用前,设置 LoginSecure 属性为 True
' 使用服务名进行连接
srv1.LoginSecure = True
srv1.Connect srvname
' 断开连接
srv1.Disconnect
Set srv1 = Nothing
End Sub

Sub CallChangeServerAuthenticationMode()
Dim constAuth As Byte
' 设置 constAuth 参数为:
' SQLDMOSecurity_Integrated 为 Windows Authentication 模式
' SQLDMOSecurity_Mixed 为 Mixed Authentication 模式
' 设置 constAuth 的默认值
constAuth = SQLDMOSecurity_Mixed
' 调用改变 SQL Server 身份认证模式的方法
ChangeServerAuthenticationMode constAuth
End Sub

原文转自:http://www.ltesting.net