Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 November 30th, 2005, 03:49 AM
Registered User
 
Join Date: Nov 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Comparing two datasets

Hello,

I need to compare two datasets (ds,ds1) and check if all the values of ds (retrieved from Excel Sheet) already exist in ds1 (retrieved from Sql Employee Table).

Opposite might not be true (means that not all the values of ds1 exist in ds.
ds1 always > ds , )

so if not, return the non-existing values in ds3 , later to inform the user that following employees not exist in the SQL table so he can add them manually using another interface.

I need to know if the Employee record from excel sheer already exist in SQL Employee table, if not pop-up window letting user know of non-existing Employees or even show it in datagrid.


Dim sConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                                       "data source=c:\PayrollJVOct2005.xls;" & _
                                       "Extended properties=""Excel 8.0; HDR=Yes;"""


        Dim jConString As String = "Data Source=JDE;Initial Catalog=PS_HAIFA;User ID=ASIF;Pwd=78612312"
        Dim jCon As New System.Data.SqlClient.SqlConnection(jConString)
        Dim Jda As New System.Data.SqlClient.SqlDataAdapter
        Dim Con As New System.Data.OleDb.OleDbConnection(sConString)
        Con.Open()


        Dim cmdSelect As New System.Data.OleDb.OleDbCommand("select * from [sheet1$]", Con)
        Dim da As New System.Data.OleDb.OleDbDataAdapter
        da.SelectCommand = cmdSelect
        Dim ds As New System.Data.DataSet
        da.Fill(ds)
        Con.Close()
        Con.Dispose()
        DR = ds.Tables(0).Rows(0)


        Dim jConString2 As String = "Data Source=EN;Initial Catalog=PS_HAIFA;User ID=ASIF;Pwd=78612312"
        Dim jCon2 As New System.Data.SqlClient.SqlConnection(jConString2)
        Dim Jda2 As New System.Data.SqlClient.SqlDataAdapter("Select aban8 from HAIFDTA.[F0101] where ABAT1='E'", jCon2)
        jCon2.Open()
        Jda2.Fill(ds1)
        jCon2.Close()
        jCon2.Dispose()

        DrEmployee = ds1.Tables(0).Rows(0)

 
Old December 2nd, 2005, 01:42 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I think you will have to loop throght each dataset and compare the rows based on your criteria. If that row does not exist, copy it to a 3rd dataset. Then you can bind that dataset to a grid to show the user what rows are missing.

Jim






Similar Threads
Thread Thread Starter Forum Replies Last Post
How i can join two datasets in only one Nosfe_X VB Databases Basics 0 June 19th, 2006 12:43 PM
comparing 2 DataSets content .Net ochanarachel General .NET 1 March 22nd, 2005 09:54 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
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.