![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | What's wrong with my SQL query ? Hello, I have a SQL query that perfectly works using *SQL Entreprise Manager*. But when i try to use the very same in a VBS script i got an error 80040E14 telling me something like : Tables or functions 'dbo.T_Missions' and 'dbo.T_Missions' have the same name. (error message here in french : http://img515.imageshack.us/my.php?i...ryerrorpu1.jpg) Please help me to solve my pb. Code is here : ------------------------------------------------------------------------- Dim Mission Mission = InputBox("Enter your mission number : " , ".: Mission Browser :." ) If IsEmpty(Mission) Then MsgBox "You pressed Cancel!", 48, "Canceling" Wscript.Quit End If Set adoRecordset = CreateObject("ADODB.Recordset") adoRecordset.ActiveConnection = "DRIVER=SQL Server;" _ & "Trusted_Connection=Yes;" _ & "DATABASE=Xpertease;SERVER=EXPERTEASE" adoRecordset.Source = "SELECT DISTINCT " _ & "T_Missions.Libellé AS Libellé_Mission, " _ & "T_Missions.Numéro AS Numéro_Mission, " _ & "T_Ingénieurs.Initiales AS Initiales_Expert, " _ & "T_TypesMissions.Libellé AS AouJ " _ & "FROM dbo.T_Ingénieurs INNER JOIN " _ & "dbo.T_Missions ON " _ & "dbo.T_Ingénieurs.ID = dbo.T_Missions.ID_Responsable INNER JOIN " _ & "dbo.T_Missions ON " _ & "dbo.T_Missions.ID_NatureOrigine = dbo.T_TypesMissions.ID " _ & "WHERE (dbo.T_Missions.Numéro = " & Mission & ")" adoRecordset.Open Do Until adoRecordset.EOF str1st = adoRecordset.Fields("Libellé").Value str2nd = adoRecordset.Fields("No_Mission").Value str3rd = adoRecordset.Fields("Titulaire").Value str4th = adoRecordset.Fields("AouJ").Value Wscript.Echo str1st & " " & str2nd & " " & str3rd & " " & str4th adoRecordset.MoveNext Loop adoRecordset.Close ------------------------------------------------------------------------- Thanks a lot to the community if you can help me. Nicolas |
My System Specs![]() |
| | #2 (permalink) |
| | Re: What's wrong with my SQL query ? I think Anthony mis-diagnosed the problem. I don't think there was any intent to JOIN to the same table twice. I think it was simply a case of naming the wrong table in the join! After all, the SELECT includes T_TypesMissions.Libellé AS AouJ and the second ON condition says ON dbo.T_Missions.ID_NatureOrigine = dbo.T_TypesMissions.ID Joining on T_Missions twice wouldn't fix the errors that would be caused by those two usages of T_TypesMissions. So I think the only error is that the SECOND & "dbo.T_Missions ON " _ should, instead, be & "dbo.T_TypesMissions ON " _ Thus: adoRecordset.Source = "SELECT DISTINCT " _ & "T_Missions.Libellé AS Libellé_Mission, " _ & "T_Missions.Numéro AS Numéro_Mission, " _ & "T_Ingénieurs.Initiales AS Initiales_Expert, " _ & "T_TypesMissions.Libellé AS AouJ " _ & "FROM dbo.T_Ingénieurs INNER JOIN " _ & "dbo.T_Missions ON " _ & "dbo.T_Ingénieurs.ID = dbo.T_Missions.ID_Responsable INNER JOIN " _ & "dbo.T_TypesMissions ON " _ & "dbo.T_Missions.ID_NatureOrigine = dbo.T_TypesMissions.ID " _ & "WHERE (dbo.T_Missions.Numéro = " & Mission & ")" |
My System Specs![]() |
| | #3 (permalink) |
| | Re: What's wrong with my SQL query ? "Old Pedant" <OldPedant@xxxxxx> wrote in message news:2E552069-84A5-4BE0-BF28-2102303B0D21@xxxxxx Quote: > I think Anthony mis-diagnosed the problem. > > I don't think there was any intent to JOIN to the same table twice. I Quote: > it was simply a case of naming the wrong table in the join! > > After all, the SELECT includes > T_TypesMissions.Libellé AS AouJ > and the second ON condition says > ON dbo.T_Missions.ID_NatureOrigine = dbo.T_TypesMissions.ID > > Joining on T_Missions twice wouldn't fix the errors that would be caused Quote: > those two usages of T_TypesMissions. > > So I think the only error is that the SECOND > & "dbo.T_Missions ON " _ > should, instead, be > & "dbo.T_TypesMissions ON " _ > > Thus: > > adoRecordset.Source = "SELECT DISTINCT " _ > & "T_Missions.Libellé AS Libellé_Mission, " _ > & "T_Missions.Numéro AS Numéro_Mission, " _ > & "T_Ingénieurs.Initiales AS Initiales_Expert, " _ > & "T_TypesMissions.Libellé AS AouJ " _ > & "FROM dbo.T_Ingénieurs INNER JOIN " _ > & "dbo.T_Missions ON " _ > & "dbo.T_Ingénieurs.ID = dbo.T_Missions.ID_Responsable INNER JOIN " _ > & "dbo.T_TypesMissions ON " _ > & "dbo.T_Missions.ID_NatureOrigine = dbo.T_TypesMissions.ID " _ > & "WHERE (dbo.T_Missions.Numéro = " & Mission & ")" > ![]() -- Anthony Jones - MVP ASP/ASP.NET |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| SP2 query... | Vista General | |||
| Tab key query | Vista General | |||