Mdeffontaines
-
28 nov. 2001 à 17:18
lolokun
Messages postés1241Date d'inscriptionmardi 10 octobre 2006StatutMembreDernière intervention27 août 2013
-
17 août 2010 à 16:03
Voici mon code (trouvé sur le forum)
Dim MaBD As Database
Dim MonRS As Recordset
Set MaBD = DBEngine.OpenDatabase("C:\Test\personnel.mdb", True, True)
Set MonRS = BDDefinitions.OpenRecordset("SELECT gestion.Nom FROM gestion;", dbOpenSnapshot)
J'obtiens l'erreur 424 ("objekt erforderlich", ce qui doit vouloir dire qu'il manque un objet)
dim strslt as string
Dim MonRS As Recordset
strslt = "SELECT gestion.Nom FROM gestion"
MonRS.Open strslt, cn, adOpenStatic, adLockReadOnly, adCmdText
tout ça dans ta form
***********************************************************
dans un module séparer
colle ce code
Option Explicit
Public cn As ADODB.connection
Public Sub connect()
Set cn = New ADODB.connection
''On Error GoTo errFind
With cn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & _
"C:\Test\personnel.mdb"
.Open
End With
Exit Sub
errFind:
MsgBox "Impossible to connect to database PDM", vbExclamation, "Error"
End
End Sub
derniere chose tu fais appel au module dans le load du la form:ecrit just
connect
voila et ça fonction, c' est plus propre!!
si pb email me
youriyox
Messages postés1Date d'inscriptionjeudi 4 juin 2009StatutMembreDernière intervention17 août 2010 17 août 2010 à 14:34
salut tt le monde
sous VB6 j'ai fais un programme qui contient des fonctions telque l'insertion dans la table "departement" de la base de donnés "gestion stock" (la base sous sql server 2000) lors de l'execution de mon programme ,un message d'erreur s'affiche "424" j'ai essayé avec tt les solutions proposé par les amis ici mais ça marche pas .
voici mon code pour toute la fenetre :
Private Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As _
Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As _
Long) As Long
'*** Fin de la function ***
'*********************************************
'*** Cette Function est de : Violent Ken de www.vbffrance.com ***
'*** Fermer un processus lancer par shell ***
Private Declare Function TerminateProcess Lib "kernel32" (ByVal ApphProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long
Private Const PROCESS_TERMINAT As Long = &H1
Private PID As Long
'*** Fin de la function ***
'Api Pause
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
'On vérifie que toutes les zones de saisie soient remplies
If Text1.Text "" Or Text2.Text "" Or Text3.Text = "" Or Text4.Text = "" Then
If Text1.Text "" Then ErreurSave Label1.Caption: GoTo message
If Text2.Text "" Then ErreurSave Label2.Caption: GoTo message
If Text3.Text "" Then ErreurSave Label3.Caption: GoTo message
If Text4.Text "" Then ErreurSave Label4.Caption: GoTo message
message:
MessageBox Me.hwnd, "Enregistrement impossible...! Veuillez remplir le champ : " & ErreurSave, "Information utilisateur", vbOKOnly Or vbExclamation
ErreurSave = ""
Exit Sub
End If
'Validation enregistrement
Departement.AddNew
'Mise à jour de l'enregistrement 'Code departement'
If (Trim(Text1.Text) = "") Then
Departement!Code_dep = Null
Else
Departement!Code_dep = UCase(Trim(Text1.Text))
End If
'Mise à jour de l'enregistrement 'Nom departement'
If (Trim(Text2.Text) = "") Then
Departement!Nom_dep = Null
Else
Departement!Nom_dep = UCase(Trim(Text2.Text))
End If
'Mise à jour de l'enregistrement 'Chef departement'
If (Trim(Text3.Text) = "") Then
Departement!Chef_dep = Null
Else
Departement!Chef_dep = UCase(Trim(Text3.Text))
End If
'Mise à jour de l'enregistrement 'Etage'
If (Trim(Text4.Text) = "") Then
Departement!Etage = Null
Else
Departement!Etage = UCase(Trim(Text4.Text))
End If
'Mise à jour de l'enregistrement dans base de donnée
Departement.Update
Departement.Requery
MessageBox Me.hwnd, "Enregistrement ok...", "Information utilisateur", vbOKOnly Or vbInformation
'Init boutons et zone de text
Command1.Enabled = True
'Init
Command1.Enabled = True
Command2_Click 'Mise à jours des zones de saisies
Exit Sub
sort:
End Sub
Private Sub Command2_Click()
Call TextFalse
Call TextFalseRecherche
'Init boutons et zone de text
Command1.Enabled = True
Command2.Enabled = True
End Sub
Private Sub Form_Load()
'Init
Command1.Enabled = True
Command2.Enabled = True
Call TextFalse
Call TextFalseRecherche
End Sub
Public Function TextFalse()
'Init textBox
If Text1.Text = "" Then
Text1.Visible = False
If Text2.Text = "" Then
Text2.Visible = False
If Text3.Text = "" Then
Text3.Visible = False
If Text4.Text = "" Then
Text4.Visible = False
End If
End If
End If
End If
End Function
Public Function TextTrue()
'Init textBox
If Text1.Text = "" Then
Text1.Visible = True
If Text2.Text = "" Then
Text2.Visible = True
If Text3.Text = "" Then
Text3.Visible = True
If Text4.Text = "" Then
Text4.Visible = True
End If
End If
End If
End If
End Function
Public Function TextFalseRecherche()
'Init textBox
If Text1.Text = "" Then
Text1.Visible = False
If Text2.Text = "" Then
Text2.Visible = False
If Text3.Text = "" Then
Text3.Visible = False
If Text4.Text = "" Then
Text4.Visible = False
lolokun
Messages postés1241Date d'inscriptionmardi 10 octobre 2006StatutMembreDernière intervention27 août 20137 17 août 2010 à 16:03
Bonjour,
Il serait préférable que tu ouvres ton propre sujet de discussion plutôt que de déterrer un post datant de 2001..
Penses aussi à la coloration syntaxique, plus simple pour lire..
Et il manque le principal, la chaîne de connexion à ta base sql, les déclarations..à quoi correspond "departement"?
Il semble que ce soit le nom de ta table mais également le nom d'un recordset?? Ce recordset est-il ouvert??
L'expérience, c'est une connerie par jour, mais jamais la même..