|
ADO链接SQL SERVER的函数.
Public Conn As New ADODB.Connection
Public Function ConnectToServerSQL(ServerName As String, DatabaseName As String, uID As String, Optional Pwd As String = "") As Boolean
On Error GoTo Err
If Conn.State <> adStateClosed Then
Conn.Close
Conn.C & Pwd & "ersist Security Info=True;User ID=" & uID & ";Initial Catalog=" & DatabaseName & ";Data Source=" & ServerName
Conn.CursorLocation = adUseClient
Conn.ConnectionTimeout = 60
Conn.CommandTimeout = 600
Conn.Open
ConnectToServerSQL = True
Exit Function
Err:
ConnectToServerSQL = False
End Function |
|