Postada em 03/11/2010 09:32 hs
vc cria um arquivo ini com essas informacoes:
[BaseDatos] IPServer=189.52.18.42 Proveedor=Microsoft.Jet.OLEDB.4.0 Datasource=\Server\Sistema SISPED\Banco\SISPED.MDB
e no modulo do vb: Public Function ReadIni(ByVal Filename As String, ByVal Section As String, ByVal Key As String) As String Dim RetVal As String * 255, Longitud As Long Longitud = GetPrivateProfileString(Section, Key, "", RetVal, 255, Filename) If Longitud > 0 Then ReadIni = Left(RetVal, InStr(RetVal, Chr(0)) - 1) End If End Function
função que chama a conexao
Public Function Carga()
xPath = App.Path G_BancoDB = xPath & IIf(Right(xPath, 1) = "", "", "") & "Banco" xDatasource = ReadIni(xPath & IIf(Right(xPath, 1) = "", "", "") & "LoadServer.ini", "BaseDatos", "Datasource") xProveedor = ReadIni(xPath & IIf(Right(xPath, 1) = "", "", "") & "LoadServer.ini", "BaseDatos", "Proveedor") Cn.CursorLocation = adUseClient Cn.ConnectionString = "Provider=" & xProveedor & "; Data Source= " & xDatasource & "; Persist Security Info=False" Cn.ConnectionTimeout = 15
If Cn.State <> 0 Then MsgBox "Servidor não Conetado: " & Cn.Version, vbInformation, "Aviso..." Set Cn = Nothing End Else Cn.Open End If
End Function
|