IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

Problème avec Inner Join


Sujet :

VB.NET

  1. #1
    Membre habitué
    Homme Profil pro
    Technicien en numérisation
    Inscrit en
    Juillet 2002
    Messages
    338
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Canada

    Informations professionnelles :
    Activité : Technicien en numérisation

    Informations forums :
    Inscription : Juillet 2002
    Messages : 338
    Points : 155
    Points
    155
    Par défaut Problème avec Inner Join
    Bonjour,

    Je veux afficher avec la requête qui va suivre les demandes selon le technicien qui les a traitées.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    "SELECT Demandes.ID_Demande as [No demande], Demandes.Date_Creation as [Date demande], Techniciens.Nom_Tech as [Nom Technicien] FROM Techniciens INNER JOIN Demandes ON Techniciens.ID_Tech = Demandes.ID_Tech"
    Je programme en VB.NET et le debug me dit qu'il y a une erreur dans la commande....
    System.Data.OleDb.OleDbException was unhandled
    ErrorCode=-2147217900
    Message="Instruction SQL non valide; 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT' ou 'UPDATE' attendus."
    Source="Microsoft JET Database Engine"
    StackTrace:
    à System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) à System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) à System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) à System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) à System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) à System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) à System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) à System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) à System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) à System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) à Gestion_Des_Services.GestionDemandes.afficher_demandes() dans K:\Programme Gestion Des Demandes\Gestion Des Services\Gestion Des Services\GestionDemandes.vb:ligne 589 à Gestion_Des_Services.GestionDemandes.GestionDemandes_Load(Object sender, EventArgs e) dans K:\Programme Gestion Des Demandes\Gestion Des Services\Gestion Des Services\GestionDemandes.vb:ligne 10 à System.EventHandler.Invoke(Object sender, EventArgs e) à System.Windows.Forms.Form.OnLoad(EventArgs e) à System.Windows.Forms.Form.OnCreateControl() à System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) à System.Windows.Forms.Control.CreateControl() à System.Windows.Forms.Control.WmShowWindow(Message& m) à System.Windows.Forms.Control.WndProc(Message& m) à System.Windows.Forms.ScrollableControl.WndProc(Message& m) à System.Windows.Forms.ContainerControl.WndProc(Message& m) à System.Windows.Forms.Form.WmShowWindow(Message& m) à System.Windows.Forms.Form.WndProc(Message& m) à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) à System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow) à System.Windows.Forms.Control.SetVisibleCore(Boolean value) à System.Windows.Forms.Form.SetVisibleCore(Boolean value) à System.Windows.Forms.Control.set_Visible(Boolean value) à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) à System.Windows.Forms.Application.Run(ApplicationContext context) à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) à Gestion_Des_Services.My.MyApplication.Main(String[] Args) dans 17d14f5c-a337-4978-8281-53493378c1071.vb:ligne 81 à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() à System.Threading.ThreadHelper.ThreadStart_Context(Object state) à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) à System.Threading.ThreadHelper.ThreadStart()
    InnerException:
    Je regarde et je ne vois pas le problème.

    Avez-vous une idée !?!?

    Merci

    AngelEvil!

  2. #2
    Membre émérite Avatar de lola06
    Femme Profil pro
    Consultante en Business Intelligence
    Inscrit en
    Avril 2007
    Messages
    1 316
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 37
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Consultante en Business Intelligence
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2007
    Messages : 1 316
    Points : 2 520
    Points
    2 520
    Par défaut
    Salut,
    As-tu essayé d'exécuter la requête à part pour voir si elle fonctionne bien seule ?
    Est-tu sûr que la commande sql est bien implémentée ?
    Tu devrais mettre ton code complet pour que ça soit plus simple pour nous.
    Mets nous aussi la structure de ta base de données...
    @+

  3. #3
    Membre habitué
    Homme Profil pro
    Technicien en numérisation
    Inscrit en
    Juillet 2002
    Messages
    338
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Canada

    Informations professionnelles :
    Activité : Technicien en numérisation

    Informations forums :
    Inscription : Juillet 2002
    Messages : 338
    Points : 155
    Points
    155
    Par défaut
    Bonjour,

    1. Ce select fonctionne parfaitement lorsque le texte saisit n'a pas de ' dans le texte.

    2. J'avais posté ce message dans le forum Access et comme vous voyez le message a été déplacé ici.

    3. Le code... le voici....

    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
            Dim strCon$ = CStr("provider=microsoft.jet.oledb.4.0;" & "data source= " & Application.StartupPath & "\" & "Demandes.mdb;")
            Dim CnEnreg As New OleDb.OleDbConnection
            Dim CmdR As New OleDb.OleDbCommand
            Dim DtsetRecherche As New DataSet
            Dim dtAdapteurRecherche As New OleDb.OleDbDataAdapter
     
            CnEnreg.ConnectionString = strCon$
            Dim requete As String = vbEmpty
     
     
            CmdR.CommandText = "SELECT Demandes.ID_Demande as [No demande], Demandes.Date_Creation as [Date demande], Techniciens.Nom_Tech as [Nom Technicien] FROM Techniciens INNER JOIN Demandes ON Techniciens.ID_Tech = Demandes.ID_Tech"
            CnEnreg.Open()
            CmdR = CnEnreg.CreateCommand() 'Creation de commande
            CmdR.CommandText = requete
     
            ' mode non connecté
     
            DtsetRecherche = New DataSet
     
     
            ' prepare le code pour afficher le resultat de la requete dans la datagridview
            dtAdapteurRecherche = New OleDb.OleDbDataAdapter
            dtAdapteurRecherche.SelectCommand = CmdR
     
            dtAdapteurRecherche.Fill(DtsetRecherche, "Demandes")
     
            Me.DG_Demandes.DataSource = DtsetRecherche.Tables("Demandes")
            Me.DG_Demandes.Refresh()
     
     
            Me.DG_Demandes.AllowUserToAddRows = False
            Me.DG_Demandes.AllowUserToDeleteRows = False
            Me.DG_Demandes.AllowUserToOrderColumns = False
            Me.DG_Demandes.Refresh()
            CnEnreg = Nothing
            CmdR = Nothing
            dtAdapteurRecherche = Nothing
            DtsetRecherche = Nothing

  4. #4
    Membre émérite Avatar de lola06
    Femme Profil pro
    Consultante en Business Intelligence
    Inscrit en
    Avril 2007
    Messages
    1 316
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 37
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Consultante en Business Intelligence
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2007
    Messages : 1 316
    Points : 2 520
    Points
    2 520
    Par défaut
    Bonjour,

    Citation Envoyé par angelevil Voir le message
    Bonjour,

    1. Ce select fonctionne parfaitement lorsque le texte saisit n'a pas de ' dans le texte.
    --> a quel moment il y a un texte saisi ? Parce que là je n'en voit pas...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
     
    ...
    Dim requete As String = vbEmpty
     
    CmdR.CommandText = "SELECT Demandes.ID_Demande as [No demande], Demandes.Date_Creation as [Date demande], Techniciens.Nom_Tech as [Nom Technicien] FROM Techniciens INNER JOIN Demandes ON Techniciens.ID_Tech = Demandes.ID_Tech"
    CnEnreg.Open()
    CmdR = CnEnreg.CreateCommand() 'Creation de commande
    CmdR.CommandText = requete
    --> ici tu assignes ta requête sql à CmdR.CommandText, mais après tu ré-assigne la variable requete, qui lui est vide... Enlève donc l'instruction CmdR.CommandText = requete et exécute ton programme. Puis dis nous si ça marche...

  5. #5
    Membre habitué
    Homme Profil pro
    Technicien en numérisation
    Inscrit en
    Juillet 2002
    Messages
    338
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Canada

    Informations professionnelles :
    Activité : Technicien en numérisation

    Informations forums :
    Inscription : Juillet 2002
    Messages : 338
    Points : 155
    Points
    155
    Par défaut
    subtilité de langue francaise...

    Bon...

    Imaginez un ecran ou il y a un Grid qui affiche les no_demande le Nom_Techncicien et la date_demande.

    Au depart du programme je veux afficher les demandes qui sont dans la BD dans le Grid!

    J'ai produit un SELECT pour faire afficher les infos. Je fais un Inner Join pour que le No_technicien dans la table Demandes et le No_Technicien dans la table TEchniciens se lient et donne le NOM du technicien.

    Vous aviez raison! Je me suis "fourré" ben raide avec la maudite ligne que j'avais mis en trop.

    Excusez du dérangement!

    Résolut et on ferme

    AngelEvil!

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. problème avec inner join
    Par minooo dans le forum Oracle
    Réponses: 2
    Dernier message: 20/12/2010, 22h08
  2. [MySQL] Problème avec INNER JOIN
    Par Tee shot dans le forum PHP & Base de données
    Réponses: 4
    Dernier message: 13/02/2008, 14h28
  3. Problème avec INNER JOIN
    Par jeanmarc1234 dans le forum Langage SQL
    Réponses: 9
    Dernier message: 14/01/2008, 15h57
  4. Problème de jointure avec INNER JOIN et LEFT OUTER JOIN
    Par tonio-lille dans le forum Langage SQL
    Réponses: 4
    Dernier message: 10/02/2006, 12h45
  5. [Oracle] problème avec INNER JOIN
    Par Philofish dans le forum Langage SQL
    Réponses: 5
    Dernier message: 15/09/2005, 10h20

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo