Bonjour Voici mon problème,
j'utilise une connexion ADO pour accéder à une base oracle (nomée BDD_POPU) mes critères de filtres sont saisis
dans un formulaire (nomé Choix_tact) qui se présente comme ceci:
***************************
IDent: A000tyn
Datefirst: 01/08/2012
Datelast: 30/08/2012
***************************
Lorsque j'utilise la valeur prise par "Datefirst" ou celle prise par "Datelast" mon code s'éxcute sans problème
mais quand j'essai de faire la même chose avec celle d' "IDent" j'obtiens l'erreur
'-2147467259 (80004005)'
Quelqu'un a une t-il une idée ?
Merci d'avance.
Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 Function papa() Const TABLE_RESULTAT = "CHOIX_Fait" Dim cn As ADODB.Connection Dim cmd As ADODB.Command Dim MonRs As ADODB.Recordset Dim oField As ADODB.Field Dim out_rst As Recordset Début = Format(Form_Choix_tact.first, "yyyy\-mm\-dd 00:00:00") Fin = Format(DateAdd("d", 1, Form_Choix_tact.last), "yyyy\-mm\-dd 00:00:00") lelogins = Form_Choix_tact.Login Set out_rst = CurrentDb.OpenRecordset(TABLE_RESULTAT) Set cn = New ADODB.Connection cn.ConnectionString = Connexion_IRRP cn.Open Set cmd = New ADODB.Command SQL = "SELECT Ct_Date, Poste1, Ville, Code_pers " _ & "FROM BDD_POPU " _ & "WHERE Poste1 = 'Directeur' " _ & "and and Ct_Date >= {ts'" & Début & "'} " _ & "and and Ct_Date < {ts'" & Fin & "'} " _ & "and Code_pers = { ts'" & lelogins & "'} " _ & " _ORDER BY Ct_Date" Debug.Print SQL With cmd .ActiveConnection = cn .CommandText = SQL Set MonRs = cmd.Execute End With MonRs.Close Set MonRs = Nothing Set MonRs = New ADODB.Recordset MonRs.Open cmd, , adOpenKeyset, adLockOptimistic, adCmdText MonRs.MoveFirst SQL = "DELETE * FROM " & TABLE_RESULTAT CurrentDb.Execute SQL Do While Not MonRs.EOF out_rst.AddNew For Each oField In MonRs.Fields out_rst.Fields(oField.Name).Value = oField.Value Next oField out_rst.Update MonRs.MoveNext Loop Set cn = Nothing Set cmd = Nothing Set out_rst = Nothing Set MonRs = Nothing End Function
C'est la ligne rouge qui pose problème, lorsque je la met en commentaire le code marche sans problème.
Partager