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.
|