Sub ToWindowsAuthentication()
Dim srv1 As SQLDMO.SQLServer
'' 指定哪个服务器,默认为 Local (本地服务器)
srvname = "(local)"
'' 使用集成安全(Windows)方式新建一个 SQL Server 对象并进行连接
Set srv1 = New SQLDMO.SQLServer
srv1.LoginSecure = True
srv1.Connect srvname
'' 设置 SecurityMode 属性为 Windows 身份验证模式
srv1.IntegratedSecurity.SecurityMode = SQLDMOSecurity_Integrated
srv1.Disconnect
'' 调用 Stop 方法停止服务器,直到服务器完全停止
srv1.Stop
Do Until srv1.Status = SQLDMOSvc_Stopped
Loop
'' 重新以混合模式启动服务器
srv1.Start True, srvname
'' 断开连接
srv1.Disconnect
Set srv1 = Nothing
End Sub
Sub WindowsToMixedAuthentication()
Dim srv1 As SQLDMO.SQLServer
'' 指定哪个服务器,默认为 Local (本地服务器)
srvname = "(local)"
'' 使用集成安全(Windows)方式新建一个 SQL Server 对象并进行连接
Set srv1 = New SQLDMO.SQLServer
srv1.LoginSecure = True
srv1.Connect srvname
'' 设置 SecurityMode 属性混合身份验证模式
srv1.IntegratedSecurity.SecurityMode = SQLDMOSecurity_Mixed
srv1.Disconnect
'' 调用 Stop 方法停止服务器,直到服务器完全停止
srv1.Stop
Do Until srv1.Status = SQLDMOSvc_Stopped
Loop
'' 重新以混合模式启动服务器
srv1.Start True, srvname
'' 断开连接
srv1.Disconnect
Set srv1 = Nothing
End Sub
Sub CallOpenADPWindowsOrSQLServer()
Dim srvname As String
Dim dbname As String
Dim prpath As String
Dim prname As String
Dim suid As String
Dim pwd As String
Dim bolWindowsLogin As Boolean
'' 设置打开 ADP 程序的参数
srvname = "(local)"
dbname = "NorthwindCS" '' ADP 连接的数据库
&nb