|
-
Jun 1st, 2008, 02:01 AM
#1
Thread Starter
Lively Member
sql involving three tables
hello..i can't get my code to work..here's the details
i have three tables
table 1 :Company_Profile
fields: address,comp_no
table 2: Project_Info
fields: pro_no, title
table 3: Company_Project
fields : com_no, pro_no
I want to link the tree tables..I have a search button..the input is address..
So, I need to get the pro_no and comp_no of the address given including the title..
this is my current code:
adodc1.recordsource = "select * from address, a.comp_no, b.pro_no from Company_Profile,Company_Profile a,Project_Info b where address = txt2.text and a.comp_no = comp_no and b.pro_no = a.pro_no"
adodc1.refresh..
please..i Need it so bad..
tnx..
Last edited by puzzleofurheart_23; Jun 1st, 2008 at 03:03 AM.
-
Jun 1st, 2008, 02:51 AM
#2
Re: sql involving three tables
This is one way
Code:
"SELECT Company_Project.pro_no AS Pro_No, Company_Project.comp_no AS Comp_No FROM Company_Project, Company_Profile WHERE Company_Profile.Address = '" & txt2.text & "'"
-
Jun 1st, 2008, 03:06 AM
#3
Thread Starter
Lively Member
Re: sql involving three tables
 Originally Posted by lintz
This is one way
Code:
"SELECT Company_Project.pro_no AS Pro_No, Company_Project.comp_no AS Comp_No FROM Company_Project, Company_Profile WHERE Company_Profile.Address = '" & txt2.text & "'"
how can I get the title?
-
Jun 1st, 2008, 03:32 AM
#4
Re: sql involving three tables
Ad that field to your select field list.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 1st, 2008, 03:45 AM
#5
Thread Starter
Lively Member
Re: sql involving three tables
 Originally Posted by RobDog888
Ad that field to your select field list.
i already did..but i want to filter it by pro_no..can you tell me what's wrong this code :
Adodc1.RecordSource = "SELECT Company_Profile.address AS address, Project_Info.title AS title, Project_Info.pro_no as Pro_no1, Company_Projects.pro_no as Pro_no2 FROM Company_Projects, Company_Profile, Project_Info WHERE Project_Info.pro_no = Company_Projects.pro_no And Company_Profile.contact_lname like " & hold
Adodc1.Refresh
I have an error..object not required.
-
Jun 1st, 2008, 03:55 AM
#6
Re: sql involving three tables
Ah you are using that ADODC data bound control. This makes things more difficult. Using all ADO code instead makes it easier but for now are you binding your controls to the fields in the data control?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 1st, 2008, 04:02 AM
#7
Thread Starter
Lively Member
Re: sql involving three tables
 Originally Posted by RobDog888
Ah you are using that ADODC data bound control. This makes things more difficult. Using all ADO code instead makes it easier but for now are you binding your controls to the fields in the data control?
I have textbox where the address will be entered..and On the interactive change of the textbox, i have a datagrid that will show the matched address. I use ADODC so that it will show all the data on real time..I need to have a double condition so that I can filter the result by pro_no bcoz it appears many times on the grid.
I can't get it to work.
Can you help me?
-
Jun 1st, 2008, 05:26 AM
#8
Re: sql involving three tables
I dont believe the adodc control has a fileter property but if you had used pure ado code then all these issues wouldnt be an issue. I dont use the ado data control for these reasons. Perhaps someone who does may know a way around that.
the only thing I can think of is to re execute a sql statement that will add the extra filtering in the where clause.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 1st, 2008, 05:50 AM
#9
Re: sql involving three tables
Thread moved to Database Development forum
 Originally Posted by puzzleofurheart_23
Adodc1.RecordSource = "SELECT Company_Profile.address AS address, Project_Info.title AS title, Project_Info.pro_no as Pro_no1, Company_Projects.pro_no as Pro_no2 FROM Company_Projects, Company_Profile, Project_Info WHERE Project_Info.pro_no = Company_Projects.pro_no And Company_Profile.contact_lname like " & hold
Adodc1.Refresh
I have an error..object not required.
I've never heard of that error.. I presume it was actually "Object required".
If that is the case, check what Adodc1 is - as that not being an Object (a control etc) is the only thing which could cause the error.
-
Jun 1st, 2008, 05:51 AM
#10
Re: sql involving three tables
I think if adodc code is in form load it may give that error as the control isnt initialized yet perhaps.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 1st, 2008, 05:58 AM
#11
Frenzied Member
Re: sql involving three tables
I dont know about the ADODC, but a SQL with INNER JOIN could get you the information.
eg:
Code:
SELECT * FROM Company_Project INNER JOIN Project_Info ON Company_Project.pro_no = Project_Info. pro_no WHERE Company_Profile.Address = '" & txt2.text & "'"
You could get Title from this.
Why dont you use ADO instaed of ADODC?
-
Jun 1st, 2008, 06:07 AM
#12
Thread Starter
Lively Member
Re: sql involving three tables
 Originally Posted by zeezee
I dont know about the ADODC, but a SQL with INNER JOIN could get you the information.
eg:
Code:
SELECT * FROM Company_Project INNER JOIN Project_Info ON Company_Project.pro_no = Project_Info. pro_no WHERE Company_Profile.Address = '" & txt2.text & "'"
You could get Title from this.
Why dont you use ADO instaed of ADODC?

i don't know how to use ado..can you give a good link where I could learn about it?
-
Jun 1st, 2008, 06:18 AM
#13
Re: sql involving three tables
See the "Classic VB - ADO" section of our Database Development FAQs/Tutorials (at the top of this forum)
-
Jun 1st, 2008, 06:20 AM
#14
Frenzied Member
Re: sql involving three tables
i don't know how to use ado..can you give a good link where I could learn about it?
Certainly, Check our own DB FAQs.
http://www.vbforums.com/showthread.php?t=337051#ado
http://www.vbforums.com/showthread.php?t=337051#bound
http://www.vbforums.com/showthread.php?t=337051
Data Bound Control is good, its easy and not much PIA, but its still better if you know whats going on.
Databound control is for lazy people who doesnt want to learn to do better. (no any offense to you though )
-
Jun 1st, 2008, 08:00 AM
#15
Re: sql involving three tables
In his other thread it was pointed out that his current statement is missing double quotes on part of the statemet.
http://www.vbforums.com/showthread.php?t=525189
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|