bilalstar
Messages postés70Date d'inscriptiondimanche 27 mars 2005StatutMembreDernière intervention 3 octobre 2005
-
17 mai 2005 à 23:34
nawakator
Messages postés51Date d'inscriptionlundi 12 mai 2003StatutMembreDernière intervention 8 février 2011
-
18 mai 2005 à 11:21
bonjour,
quelqu'un pourra m'expliquer en bref cmt connecter ma base de donnes sql serever 2000 a mon application vb6.
merci d'avance.
nawakator
Messages postés51Date d'inscriptionlundi 12 mai 2003StatutMembreDernière intervention 8 février 2011 18 mai 2005 à 11:21
Tu doit avoir microsoft DAO 3.6 Objet Library ou plus d'installer en référence
( installer MDAC )
Voici une solution avec une connexion OLE bien plus éfficace que ODBC
----------------- Variables :
Global strProvider As String
Global strNomBase As String
Global strServeur As String
Global strUtilisateur As String
Global strPassword As String
Global pServeur As New ADODB.Connection
global strTable as string
--------------- fonction connexion
Dim strConnexion As String
' Création canal de communication avec le serveur SQL
With pServeurFrigo
' - Provider
.Provider = strProvider
' - Chaine de communication
.ConnectionString = strConnexion
' - Différents time-out
.ConnectionTimeout = 6
.CommandTimeout = 60
' - Ouverture connexion
.Open
End With
--------------- fonction déconnexion
Sub FermetureConnect()
' Fermeture de la connexion au serveur
pServeur.Close
Set pServeur = Nothing
--------------- fonction recherche
Sub Recherche()
Dim pRecordSet As New ADODB.Recordset
' Ouverture de la table et recherche
pRecordSet.Open "SELECT * FROM " + strTable + _
"WHERE Piles ='' ORDER By Piles" + _
OBJ_ServeurFrigo, adOpenDynamic, adLockOptimistic
' Si pile trouvée
If pRecordSet.EOF = False Then
' Traitement
' Fermer
pRecordSet.Close
End If
set pRecordSet = nothing
J'espere que ca t'aidera. J'ai fait des copiés coller d'une autre appli mais j'ai pas tester ces lignes ( le principe et bon en tout cas) .