Dim cn As New ADODB.ConnectionOn Error GoTo ErrorHandlerIf Text1.Text = "" Then MsgBox "请输入服务器名!", vbExclamation Exit Sub End Ifcn.ConnectionString = "driver={SQL Server};server=" & Text1.Text & ";uid=uid;pwd=pwd;database=master" cn.OpenExit SubErrorHandler: MsgBox "不能连接到服务器!"
MsgBox "请输入服务器名!", vbExclamation
Exit Sub
End Ifcn.ConnectionString = "driver={SQL Server};server=" & Text1.Text & ";uid=uid;pwd=pwd;database=master"
cn.OpenExit SubErrorHandler:
MsgBox "不能连接到服务器!"