I want to compare the stock records in the IBM DB2 database with the table in the SQL database and import the different records into a dataview. Then I will transfer different records to the SQL table.
I am currently getting the records I want from the db2 stock table, but I could not find how to compare them with the SQL stock table. I think I need to assign a field to the db2 virtual stock table. I want to compare the stock codes and get different records.
I will also put a check at the beginning of different records and transfer them to the SQL stock table.
public partial class frmStok : MetroFramework.Forms.MetroForm
{
DB2Connection db2bagla = new DB2Connection(frmMain.settings.db2con);
SqlConnection sqlbagla = new SqlConnection(frmMain.settings.sqlcon);
public frmStok()
{
InitializeComponent();
}
void db2StokGetir()
{
try
{
DB2DataAdapter db2da = new DB2DataAdapter("SELECT DISTINCT S.PARCAKOD,P.ADI,P.BIRIM,P.KDVYUZ,P.GRUP1 FROM DB2ADMIN.T0020031 S LEFT OUTER JOIN DB2ADMIN.T0050030 P ON S.PARCAKOD = P.KOD WHERE ((YEAR( S.TARIH) >= 2023)) GROUP BY S.PARCAKOD,P.ADI,P.BIRIM,P.KDVYUZ,P.GRUP1", db2bagla);
SqlDataAdapter sqlda = new SqlDataAdapter("SELECT STOK_KODU FROM TBLSTSABIT", sqlbagla);
DataSet db2stok = new DataSet();
DataSet sqlstok = new DataSet();
db2da.Fill(db2stok, "DMSSTOK");
sqlda.Fill(sqlstok, "SQLSTOK");
metroGrid1.DataSource = db2stok.Tables[0];
metroLabel1.Text=metroGrid1.RowCount.ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
1条答案
按热度按时间7fyelxc51#
I suggest you use LINQ after you fill the dataset.
Make sure you the LINQ reference:
Here's a sample