DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Visual Basic 4 / 5 / 6 (http://www.daniweb.com/forums/forum4.html)
-   -   Joining two tables in VB 6 (http://www.daniweb.com/forums/thread90493.html)

jhowell Sep 23rd, 2007 12:46 pm
Joining two tables in VB 6
 
hi to everyone,
Im creating an application which it can show all records of the two tables in single form. its like costumerTable and OrderList. how can i show a record of specific costumer from costumertable together with his product order details from OrderList table. Supposed I have costumerNo field from my costumertable and also i have costumerNo field in my Orderlist table. I also wants to show the order details in datagrid view supposed costumer bought 5 items. can anyone help me find solution. any help we'll be appreciated. thanks

plusplus Sep 24th, 2007 2:27 am
Re: Joining two tables in VB 6
 
let's say you have variable costumernr with the costumer's nummer and variable amount
adodc1.recordsource = "Select * from tblorder where costumerno = " & costumernr
adodc1.refresh
amount = adodc1.recordcount 'gives you the amount of records with that costumer nummer

do while not adodc1.recordset.eof
'do whatever you want to do with the orders of that costumer nummer
loop

debasisdas Sep 24th, 2007 4:37 am
Re: Joining two tables in VB 6
 
Join both the tables using SQL command and display the output on grid.

ryan_vietnow Sep 24th, 2007 11:48 am
Re: Joining two tables in VB 6
 
Join the 2 tables by use of the LEFT JOIN command in SQL.

jhowell Sep 24th, 2007 1:26 pm
Re: Joining two tables in VB 6
 
Quote:

Originally Posted by debasisdas (Post 439931)
Join both the tables using SQL command and display the output on grid.

can you please show me your code in LEFT JOIN. I really do not know how is it. thanks

debasisdas Sep 25th, 2007 7:14 am
Re: Joining two tables in VB 6
 
Kindly post both of your tables structure for further details on JOIN.

jhowell Sep 27th, 2007 2:46 pm
Re: Joining two tables in VB 6
 
lets say from Customer Table I have CustCode, CustName, CustAdd, CustTel. from my OrderList I have CustCode, PONum, ItemName, QTY, Amt.

I want to get all the records that my customer bought. e.i. customer bought 5 items. the other day he bought 10 items. how can i use sql to join two tables to be able to show the record which my customer bought (the 10 items). what should i do. is there any changes to my table structure for this..kindly post your suggestion please...

jhowell Sep 27th, 2007 2:47 pm
Re: Joining two tables in VB 6
 
lets say from Customer Table I have CustCode, CustName, CustAdd, CustTel. from my OrderList I have CustCode, PONum, ItemName, QTY, Amt.

I want to get all the records that my customer bought. e.i. customer bought 5 items. the other day he bought 10 items. how can i use sql to join two tables to be able to show the record which my customer bought (the 10 items). what should i do. is there any changes to my table structure for this..kindly post your suggestion please...

leovicAustria Sep 27th, 2007 7:39 pm
Re: Joining two tables in VB 6
 
Quote:

Originally Posted by jhowell (Post 439587)
hi to everyone,
Im creating an application which it can show all records of the two tables in single form. its like costumerTable and OrderList. how can i show a record of specific costumer from costumertable together with his product order details from OrderList table. Supposed I have costumerNo field from my costumertable and also i have costumerNo field in my Orderlist table. I also wants to show the order details in datagrid view supposed costumer bought 5 items. can anyone help me find solution. any help we'll be appreciated. thanks

>>try to used Query...In mS access

ryan_vietnow Sep 28th, 2007 4:00 pm
Re: Joining two tables in VB 6
 
this is the query:
"SELECT CustName, CustAdd, CustTel.,
PONum, ItemName, QTY, Amt.
FROM Customer
LEFT JOIN OrderList
USING (CustCode)
WHERE CustCode='*your input****' ";
Got it?
Hope it helps....


All times are GMT -4. The time now is 4:38 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC