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