cNx.Provider = "LCPI.IBProvider;auto_commit=True;ctype=?"
Option Explicit 'Déclaration des variables globales Global Liberreur As String Public cNx As New ADODB.connection Public rSt As New ADODB.Recordset Public cMd As New ADODB.Command 'Public cn_clone As New IBPSamples.TADOConnectionClone Sub ouvetrure_BD() '(Sql As String) 'Cette procédure appelle la fonction d'ouverture de la BD et affiche la fenêtre d'acceuil. Dim Sql As String If OuvrirBase = True Then Sql = "INSERT INTO TRUC " & _ " (MACHIN) " & _ "VALUES ('vince');" Debug.Print Sql rSt.Open Sql, cNx, adOpenStatic, adLockReadOnly, adCmdText 'rSt.Close 'cNx.Close Set rSt = Nothing 'Set sql = Nothing Set cNx = Nothing Else MsgBox ("La connexion n'a pas réussi,réessayez") End If End Sub Public Function OuvrirBase() As Boolean Set cNx = New ADODB.connection cNx.Provider = "LCPI.IBProvider;auto_commit=True;ctype=WIN1252" cNx.Open "C:\Devis\DEVIS.FDB", "SYSDBA", "masterkey" cMd.ActiveConnection = cNx OuvrirBase = True Exit Function '\gbemich\GESPARC\Application\ Erreur: Liberreur = "Erreur d'ouverture de la Base" OuvrirBase = False End Function
cnx.Execute "INSERT INTO [CONTACT] " & _ " ([NOM],[PRENOM]) " & _ "VALUES ('toto', 'JUju')"
With cnnSqlServer ' Referme si déjà ouverte If .State <> adStateClosed Then .Close ' Paramétrage connexion .ConnectionTimeout = 25 .Provider = "sqloledb" .Properties("Data Source").Value = ServerName .Properties("Initial Catalog").Value = DBName ' SQL Server dédié .Properties("Locale Identifier").Value = 1033 ' impose Anglais .Properties("User ID").Value = sUserID .Properties("Password").Value = sPassword On Error Resume Next ' Connexion .Open ' Attend connexion terminée Do While .State = adStateConnecting DoEvents Loop On Error GoTo 0 ' Au final, renvoie True si on est bien ouvert ConnectSqlServer CBool(.State adStateOpen) End With
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.