Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2006, 12:43 PM
Registered User
 
Join Date: Jun 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Nosfe_X
Default How i can join two datasets in only one

Hi


I have problems try'in join 2 datasets in only one, my two datasets have 2 two fields in each dataset one with Partnumber and the another field with the attribute. It is my code:


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        xlsel = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Proyecto RECON Report\v0.1\RECON REPORT\recon_db.mdb"
        Try
            'Open connection
            bdconnection = New OleDbConnection(xlsel)
            bdconnection.Open()
        Catch ex As Exception
            MsgBox(" Error openning the connection :" & vbCrLf & ex.Message)
            Labled.Text = "Error"
            Exit Sub
        End Try

        ds2excel = New Data.DataSet
        xlsel = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Proyecto RECON Report\v0.1\RECON REPORT\recon_db.mdb"
        Try
            'Open connection
            bdconnection = New OleDbConnection(xlsel)
            bdconnection.Open()
        Catch ex As Exception
            MsgBox(" Error openning the connection :" & vbCrLf & ex.Message)
            Exit Sub
        End Try

        ds2excel = New Data.DataSet
        'master part_numbs
        xsqlmst = "Select masters.[Part Number] from masters"

        'ercw data
        'ercw Def_Shipments
        xsql = "SELECT ercw.PARTNUMBER, Count([ercw.OUTCOME_CODE]) AS Def_Shipments " & _
               "FROM ercw " & _
               "GROUP BY ercw.PARTNUMBER, ercw.OUTCOME_CODE " & _
               "HAVING (((ercw.OUTCOME_CODE)= 'IW'))" & _
               "ORDER BY ercw.PARTNUMBER, ercw.OUTCOME_CODE;"

bdmstadapter = New OleDbDataAdapter(xsqlmst, bdconnection)
        bdadapter = New OleDbDataAdapter(xsql, bdconnection)

Try
            bdmstadapter.Fill(dsmasters)
            bdmstadapter.Dispose()

            bdadapter.Fill(dsDefShip)
            bdadapter.Dispose()

bdconnection.Close()

        Catch ex As Exception
            MessageBox.Show("Error charging the dataset: " & vbCrLf & ex.Message)
        End Try

        'Fill the dataset

        Dim ds2row As DataRow
        ds2excel.Tables.Add("RECON_REPORT")
        ds2excel.Tables("RECON_REPORT").Columns.Add("PARTN UMBER")
        ds2excel.Tables("RECON_REPORT").Columns.Add("DEF_S HIPMENTS")

'here is my problem
ds2row.Item("PARTNUMBER") = dsmasters
        For Counter = 0 To dsDefShip.Tables(1).Rows.Count
            If dsDefShip.Tables(0).Rows(Counter).Item().tostring( ) = dsmasters.Tables(0).Rows(Counter).Item().tostring( ) Then
                ds2row = dsDefShip.Tables("DEF_SHIPMENTS").NewRow()
                ds2row.Item("DEF_SHIPMENTS") = dsDefShip.Tables(1).Rows(Counter).Item
            Else
            End If
        Next Counter

I glad your help.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Find five Datasets rosejeep SQL Server 2000 1 November 9th, 2006 08:44 AM
Datasets Louisa VB.NET 2002/2003 Basics 1 October 6th, 2004 07:38 AM
DataSets CodeMonkeys C# 1 September 7th, 2004 09:48 PM
Oracle 8i inner join and left join problem puteri_84 Oracle 2 August 19th, 2004 07:14 AM
Comparing DataSets. jitu ADO.NET 1 June 7th, 2004 11:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.