Results 1 to 6 of 6

Thread: Vb.net inner join

  1. #1
    Member
    Join Date
    Sep 11
    Posts
    54

    Post 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?

  2. #2
    Burning Member Niya's Avatar
    Join Date
    Nov 11
    Posts
    3,094

    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.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | Create Sortable BindingList(not mine) | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  3. #3
    Member
    Join Date
    Sep 11
    Posts
    54

    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.

  4. #4
    Member
    Join Date
    Sep 11
    Posts
    54

    Re: Vb.net inner join

    when i run the program im getting an error on


    da.Fill(ds, "tblproduct")

  5. #5
    Member
    Join Date
    Sep 11
    Posts
    54

    Re: Vb.net inner join

    i did it already ! thank you !!!

  6. #6
    Burning Member Niya's Avatar
    Join Date
    Nov 11
    Posts
    3,094

    Re: Vb.net inner join

    Quote Originally Posted by bjay_tiamsic26 View Post
    when i run the program im getting an error on


    da.Fill(ds, "tblproduct")
    What error are you getting ?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | Create Sortable BindingList(not mine) | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •