|
-
Sep 1st, 2012, 11:03 PM
#1
Thread Starter
Addicted Member
Vb.net inner join
hi there..
im having trouble with my codes for inner join.. actually. i think my sql inner join is correct but the codes succeeding are in wrong format . please anyone help me ,,
ihave tables... namely tblproduct, tblsupplier, tblproductline, tblartist
here's my code..
Public cs As String = "Server=localhost;User Id=root;Password=;Database=koninventory"
Public sqlConn As MySqlConnection = New MySqlConnection
sqlConn.ConnectionString = cs
Try
If sqlConn.State = ConnectionState.Closed Then
sqlConn.Open()
Else
sqlConn.Close()
MsgBox("ERROR")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Dim query As String = "SELECT tblproduct.Product_ID, tblproduct.Product_Name, tblproduct.Product_Desc, tblproduct.Product_Category, tblproduct.Availability, tblproduct.Unit_Price, tblproduct.Selling_Price, tblsupplier.Supplier_Name, tblproductline.Product_Line_Desc, tblartist.Artist_Name FROM ((tblproduct INNER JOIN tblproductline ON tblproduct.Product_Line_ID = tblproductline.Product_Line_ID) INNER JOIN tblartist ON tblproduct.Artist_ID tblartist.Artist_ID) INNER JOIN tblsupplier ON tblproduct.Supplier_ID = tblsupplier.Supplier_ID;"
Dim da As New MySqlDataAdapter(query, sqlConn)
Dim ds As New DataSet
da.Fill(ds, "tblproduct") --> what table am i going to put here?
gridProductList.DataSource = ds.Tables("tblproduct") --> also here
sqlConn.Close()
ARE MY CODES CORRECT?
-
Sep 1st, 2012, 11:17 PM
#2
Re: Vb.net inner join
What do you want your query to do that it isn;t doing ? You should note that inner joins only returns rows from both tables that actually match, if that helps whatever problem you're having.
-
Sep 1st, 2012, 11:46 PM
#3
Thread Starter
Addicted Member
Re: Vb.net inner join
the tblproduct has the fields: Product_ID(PK), Product_Name, Product_Desc, Product_Category, Availability, Unit_Price, Selling_Price, Product_Line_ID(FK), Supplier_ID(FK), Artist_ID(FK)
tblproductline: Product_Line_ID(PK), Product_Line_Desc
tblsupplier: Supplier_ID(PK), Supplier_Name
tblartist: Artist_ID(PK), Artist_Name
i want to display these records, but instead of Product_Line_ID, Supplier_ID, Artist_ID, iwant to display Product_Line_Desc, Supplier_Name, Artist_Name.
-
Sep 1st, 2012, 11:50 PM
#4
Thread Starter
Addicted Member
Re: Vb.net inner join
when i run the program im getting an error on
da.Fill(ds, "tblproduct")
-
Sep 2nd, 2012, 12:16 AM
#5
Thread Starter
Addicted Member
Re: Vb.net inner join
i did it already ! thank you !!!
-
Sep 2nd, 2012, 04:01 PM
#6
Re: Vb.net inner join
 Originally Posted by bjay_tiamsic26
when i run the program im getting an error on
da.Fill(ds, "tblproduct")
What error are you getting ?
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
|