vingrid6
Messages postés13Date d'inscriptionlundi 29 novembre 2004StatutMembreDernière intervention20 décembre 2004
-
8 déc. 2004 à 15:50
thierrydelepine
Messages postés521Date d'inscriptionmardi 24 décembre 2002StatutMembreDernière intervention11 septembre 2008
-
8 déc. 2004 à 22:21
Voilà ce que j'ai commencé à écrire pour me connecter à la base et quand je compile le programme ne rentre pas dans ma fonction
si quelqu'un a une idée celle ci est la bienvenue
'Ecriture d'une fonction permettant de se connecter à la base de donnée oracle
Option Explicit
Dim Initconnexion As Boolean
Private connexion As String
Private strErreur As String
Dim chaineConnexion As ADODB.Connection
Public Function InitConnection_Initialize() As Boolean
MsgBox "bonjour"
'on ouvre la connexion
On Error GoTo Badconnexion
Set chaineConnexion = New ADODB.Connection
With chaineConnexion
.ConnectionString = connexion
.CursorLocation = adUseClient
.Open
End With
MsgBox "connexion en cours"
DataEnvironnementTEST.CARTE.ConnexionString = chaineConnexion
MsgBox "connexion après data"
InitConnection_Initialize = True
Exit Function
Appel de la fonction dans sub form_load
Public Sub Form_Load()
MsgBox "bonjour"
Dim basemode As Boolean
Dim verification As Boolean
If basemode = 1 Then
MsgBox "on est en mode globale"
'on va se connecter à oracle
verification = InitConnection_Initialize()
Select Case verification
Case True
MsgBox "Connexion OK", vbExclamation, "Connexion"
Case False
MsgBox "Non Connecté", vbExclamation, "Erreur"
Exit Sub
Case Else
MsgBox "Erreur non conu", vbExclamation, "Erreur"
Exit Sub
End Select
Else: basemode = False
MsgBox "on est en mode local"
End If
End Sub
Badconnexion:
If strError = 3255 Then
MsgBox "Erreur à la connexion: " & _
"La Connexion à la base de données n'a pas pu s'établir"
End If
If strError = 3709 Then
MsgBox "Erreur à la connexion: " & _
"Il y a un Erreur dans le Reseau, c'est un erreur exterieur"
End If
Set chaineConnexion = New ADODB.Connection
With chaineConnexion
.ConnectionString = connexion
.CursorLocation = adUseClient
.Open
End With
MsgBox "connexion en cours"
DataEnvironnementTEST.CARTE.ConnexionString = chaineConnexion
MsgBox "connexion après data"
InitConnection_Initialize = True
Exit Function
Badconnexion:
If strError = 3255 Then
MsgBox "Erreur à la connexion: " & _
"La Connexion à la base de données n'a pas pu s'établir"
End If
If strError = 3709 Then
MsgBox "Erreur à la connexion: " & _
"Il y a un Erreur dans le Reseau, c'est un erreur exterieur"
End If
InitConection_Initialize = False
End Function
Sub Form_Load()
MsgBox "bonjour"
Dim basemode As Boolean
Dim verification As Boolean
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'il faut que basemode soit a True
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
basemode = True
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If basemode = True Then
MsgBox "on est en mode globale"
'on va se connecter à oracle
verification = InitConnection_Initialize()
Select Case verification
Case True
MsgBox "Connexion OK", vbExclamation, "Connexion"
Case False
MsgBox "Non Connecté", vbExclamation, "Erreur"
Exit Sub
Case Else
MsgBox "Erreur non conu", vbExclamation, "Erreur"
Exit Sub
End Select