Need to inner join two tables in a dataset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kjewell23
    New Member
    • Sep 2007
    • 49

    Need to inner join two tables in a dataset

    Hi. I have look but can't find or understand what I need to do here. I need to join two tables together with a common field which is prdno Here is my code. please help me If I'm doing it wrong.

    [vb-code]
    Dim connectionstrin g As String

    connectionstrin g = "DRIVER=Cli ent Access ODBC Driver (32-bit);UID=xxxxxx ;PWD=xxxxxxx;Sy stem=xxx.xxx.xx x"

    Dim Order As Integer
    Order = CInt(txtOrderNu mber.Text)
    Dim myConnection As New Data.Odbc.OdbcC onnection(conne ctionstring)
    Dim mysql As String = "select line#, ordno, quano, quana, quans, c2rdt, unitm, prdno, actsp from rmsfiles2.obcop 200 where ordno = " & Order.ToString( )
    Dim command As New Data.Odbc.OdbcC ommand(mysql)
    command.Connect ion = myConnection
    Dim adapter As OdbcDataAdapter = New OdbcDataAdapter (command)
    Dim ds As DataSet = New DataSet()
    adapter.SelectC ommand = New OdbcCommand("se lect rmsfiles2.obcop 200.line#, rmsfiles2.mspmp 100.ptyp1, rmsfiles2.mspmp 100.ptyp2, rmsfiles2.obcop 200.quano, rmsfiles2.obcop 200.quana, rmsfiles2.obcop 200.quans, rmsfiles2.obcop 200.c2rdt,rmsfi les2.mspmp100.p rdno, rmsfiles2.obcop 200.unitm, rmsfiles2.mspmp 100.descp, rmsfiles2.obcop 200.actsp, rmsfiles2.obcop 200.ordno from rmsfiles2.obcop 200 inner join rmsfiles2.mspmp 100 on rmsfiles2.obcop 200.prdno = rmsfiles2.mspmp 100.prdno where rmsfiles.obcop2 00.ordno = " & Order.ToString( ), myConnection)
    adapter.Fill(ds )

    gridview1.DataS ource = ds
    gridview1.DataB ind()
    [/vb-code]
    Last edited by kjewell23; Sep 24 '07, 01:36 PM. Reason: for to end the code
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    This is really an SQL based question, not .net.
    Perhaps a mod could move it for you?

    Comment

    • kjewell23
      New Member
      • Sep 2007
      • 49

      #3
      what do you mean by that a mod could move it for you
      Originally posted by Plater
      This is really an SQL based question, not .net.
      Perhaps a mod could move it for you?

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Originally posted by kjewell23
        what do you mean by that a mod could move it for you
        Well the .NET section is not the best place to get help on SQL statements, so they could move it to the correct section where the experts there would be of more help.

        Comment

        Working...