www.pudn.com > VBproject VCD.rar > ServerConnect.bas, change:2003-05-30,size:941b


Attribute VB_Name = "ServerConnect" 
Public con As Connection 
Dim rst As Recordset 
 
Public Function Connect() As Connection 
Set con = New Connection 
'Set com = New Command 
Set rst = New Recordset 
Dim strserver As String 
Dim struser As String 
Dim strpass As String 
Dim strbase As String 
'On Error GoTo err 
strserver = GetSetting("ServerInfo", "Sql server", "ServerName") 
struser = GetSetting("ServerInfo", "Sql server", "ServerUser") 
strpass = GetSetting("ServerInfo", "Sql server", "ServerPassword") 
strbase = GetSetting("ServerInfo", "Sql server", "ServerBase") 
With con 
    .ConnectionString = "user id =" & struser & ";password=" & strpass & ";data source=" & strserver & ";initial catalog =" & strbase 
    .Provider = "sqloledb" 
    'MsgBox struser 
    .Open 
End With 
'rst.Open " " & str & " ", con, adOpenDynamic, adLockOptimistic 
'rst.Close 
'con.Close 
'err: 
'MsgBox err.Description 
'con.Close 
End Function