Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1443 connectés 

  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  Impossible de trouver l'objet dans la collection correspondant au nom

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Impossible de trouver l'objet dans la collection correspondant au nom

n°2002667
ajor2
Posté le 18-06-2010 à 10:32:25  profilanswer
 

Bonjour,
 
En ouvrant mon fichier Excel, j'obtiens une erreur :

Code :
  1. 3265
  2. Impossible de trouver l'objet dans la collection correspondant au nom ou à la référence ordinale demandé


 
Le code contient une requête SQL qui fonctionne très bien quand je la fais directement dans Oracle (par SQL+)
 
Voici la requête :
 

Code :
  1. strSQL = "select cote.indice, cote.cote_actuelle " & _
  2.                 "from t_detail_vin pr, type_vin vin, (select ind.id_tvin,ind.milesime millesime,c.cote cote_actuelle, ind.id_indice indice from t_indices ind,cote_annuelle c where ind.id_indice = c.id_indice and   ind.format in('Bouteille') and  c.annee='2010' and ind.id_indice not in ('1','2','3') and ind.id_indice < '100') cote" & _
  3.                 "where vin.id_tvin = pr.id_tvin and pr.milesime = cote.millesime and vin.id_tvin=cote.id_tvin and vin.proprietaire not in ('Indifferent') and vin.proprietaire is not null order by cote.indice"


       
 
A votre avis, d'où vient l'erreur ?
 
Précision : je travaille sur Excel 2003, j'appelle une base Oracle 10g avec cette fonction (qui fonctionne très bien avec des requêtes simples):

Code :
  1. Set cN = New ADODB.Connection
  2.     cN.ConnectionString = "Provider=msdaora;Data Source=OIU;User Id=XXXXX;Password=XXXX;"

mood
Publicité
Posté le 18-06-2010 à 10:32:25  profilanswer
 

n°2002712
SuppotDeSa​Tante
Aka dje69r
Posté le 18-06-2010 à 11:51:20  profilanswer
 

Hello
 
Perso je ne vois pas d'espace entre cote et where, donc ta chaine doit renvoyer cotewhere
 

Citation :

strSQL = "select cote.indice, cote.cote_actuelle " & _
                "from t_detail_vin pr, type_vin vin, (select ind.id_tvin,ind.milesime millesime,c.cote cote_actuelle, ind.id_indice indice from t_indices ind,cote_annuelle c where ind.id_indice = c.id_indice and   ind.format in('Bouteille') and  c.annee='2010' and ind.id_indice not in ('1','2','3') and ind.id_indice < '100') cote" & _
                "where vin.id_tvin = pr.id_tvin and pr.milesime = cote.millesime and vin.id_tvin=cote.id_tvin and vin.proprietaire not in ('Indifferent') and vin.proprietaire is not null order by cote.indice"


Message édité par SuppotDeSaTante le 18-06-2010 à 11:51:47

---------------
Soyez malin, louez entre voisins !
n°2002726
ajor2
Posté le 18-06-2010 à 12:01:32  profilanswer
 

Salut !
 
Sans l'espace, on obtient l'erreur suivante à l'execution :
 
ORA-00933: SQL command not properly ended
 
Si je met l'espace on obtient l'erreur décrite plus haut (petit oubli dans mon copier coller).
Je précise qu'à l'execution, il n'y a aucune erreur.
C'est en ouvrant le fichier Excel que j'obtiens l'erreur 3265

n°2002733
SuppotDeSa​Tante
Aka dje69r
Posté le 18-06-2010 à 12:11:22  profilanswer
 

Et dans les references tu les as bien toutes ?


---------------
Soyez malin, louez entre voisins !
n°2002739
ajor2
Posté le 18-06-2010 à 12:35:12  profilanswer
 

Oui, je pense que c'est bon de ce côté puisqu'une requête simple comme celle-ci fonctionne bien
 
strSQL = "select nom, prenom " & _  
             "from individu " & _  
             "where num = '12'"
 
Il y a peut être un problème avec la présence de deux select dans ma requête. Mais comment détourner le probleme ?

n°2002755
SuppotDeSa​Tante
Aka dje69r
Posté le 18-06-2010 à 13:39:06  profilanswer
 

Bah je vois pas le rapport entre une chaine, peu importe a quoi elle sert par la suite, et l'ouverture d'un fichier Excel...


---------------
Soyez malin, louez entre voisins !
n°2002756
SuppotDeSa​Tante
Aka dje69r
Posté le 18-06-2010 à 13:41:00  profilanswer
 

Citation :

Impossible de trouver l'objet dans la collection correspondant au nom ou à la référence ordinale demandé.  
cette erreur signifie qu'il ne trouve pas un des champs que tu as précisé dans le select  
controle qu'ils sont tous écrit correctement


---------------
Soyez malin, louez entre voisins !
n°2002763
ajor2
Posté le 18-06-2010 à 14:03:45  profilanswer
 

Voici tout le code :
 

Code :
  1. Option Explicit
  2. Public cN As ADODB.Connection
  3. Public rs As ADODB.Recordset
  4. Public Function conNect() As Boolean
  5.    
  6.     On Error GoTo conNect_Err
  7.     Set cN = New ADODB.Connection
  8.     cN.ConnectionString = "Provider=msdaora;Data Source=OIIUI;User Id=xxxxxxx;Password=xxxxxxxxxx;"
  9.     cN.Open
  10.     conNect = True
  11.     Exit Function
  12.    
  13. conNect_Err:
  14.     MsgBox Err.Number & vbCr & Err.Description
  15.     conNect = True
  16.    
  17. End Function
  18. Public Function DeconNect() As Boolean
  19.     On Error Resume Next
  20.     cN.Close
  21.     Set cN = Nothing
  22.    
  23. End Function
  24. Private Sub Workbook_Open()
  25. Dim strSQL As String
  26. Dim i As Integer
  27. Dim j As Integer
  28.     On Error GoTo Workbook_Open_Err
  29.    
  30.     If conNect() = True Then
  31.    
  32.         Set rs = New ADODB.Recordset
  33.         rs.CursorLocation = adUseClient
  34.        
  35. strSQL = ""
  36. strSQL = strSQL & "select cote.indice, "
  37. strSQL = strSQL & "       cote.cote_actuelle "
  38. strSQL = strSQL & "  from t_detail_vin pr, "
  39. strSQL = strSQL & "       type_vin vin, "
  40. strSQL = strSQL & "      (select ind.id_tvin, "
  41. strSQL = strSQL & "              ind.milesime millesime, "
  42. strSQL = strSQL & "              c.cote cote_actuelle, "
  43. strSQL = strSQL & "              ind.id_indice indice "
  44. strSQL = strSQL & "         from t_indices ind, "
  45. strSQL = strSQL & "              cote_annuelle c "
  46. strSQL = strSQL & "        where ind.id_indice = c.id_indice"
  47. strSQL = strSQL & "          and ind.format in('Bouteille') "
  48. strSQL = strSQL & "          and c.annee='2010' "
  49. strSQL = strSQL & "          and ind.id_indice not in ('1','2','3') "
  50. strSQL = strSQL & "          and ind.id_indice < '100') cote "
  51. strSQL = strSQL & "  where vin.id_tvin = pr.id_tvin "
  52. strSQL = strSQL & "    and pr.milesime = cote.millesime "
  53. strSQL = strSQL & "    and vin.id_tvin=cote.id_tvin "
  54. strSQL = strSQL & "    and vin.proprietaire not in ('Indifferent') "
  55. strSQL = strSQL & "    and vin.proprietaire is not null "
  56. strSQL = strSQL & "  order by cote.indice"
  57.       rs.Open strSQL, cN, adOpenForwardOnly, adLockOptimistic
  58.        
  59.         If rs.RecordCount > 0 Then
  60.        
  61.             j = 1
  62.             i = 0
  63.            
  64.           Do While Not rs.EOF And Not rs.BOF
  65.                
  66.     i = i + 1
  67.     Feuil1.Cells(i, j) = rs("cote.indice" )
  68.     Feuil1.Cells(i, j + 1) = rs("cote.cote_actuelle" )
  69.     rs.MoveNext
  70.                
  71. Loop
  72.            
  73.         End If
  74.        
  75.         DeconNect
  76.        
  77.     Else
  78.    
  79.         'blablabla
  80.        
  81.     End If
  82.    
  83.     Exit Sub
  84. Workbook_Open_Err:
  85. MsgBox Err.Number & vbCr & Err.Description
  86. End Sub


 
Ecrit de cette manière, il y a effectivement un message d'erreur à la compilation à la ligne  

Code :
  1. MsgBox Err.Number & vbCr & Err.Description


 
C'est le meme message...
 
Est-ce que ça viendrait du fait que mes variables contiennent des point : "cote.indice" et "cote.cote_actuelle" ?


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  Impossible de trouver l'objet dans la collection correspondant au nom

 

Sujets relatifs
[opengl] projection objet 3dMethode permettant de bien affiché un objet
visualiser objet dessiner en opengl dans une fenêtre opencvImpossible d'executer un programme après compilation (DLL manquante)
[resolu][PHP] parcourir un tableau d'objetAcceder aux attributs d'un objet dans une liste
[Résolu] Création de dossier et fichier impossiblePb d'affichage conditionnel d'objet dans un état
Update impossible PHP/ACCESS 
Plus de sujets relatifs à : Impossible de trouver l'objet dans la collection correspondant au nom


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR