Click here to Skip to main content
13,142,883 members (54,828 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am trying to Merge two DataSets in c# .net framework 4.0, It raised " Mismatch columns in the PrimaryKey : versus " My 1st Dataset is from SQl Server of DataType "Varchar", while Other is from Oracle Database of DataType "Varchar2".
OrgStockMaster.PrimaryKey = new DataColumn[] { OrgStockMaster.Columns["PkID001"] }; //SQL Database
dtOracleStock.PrimaryKey = new DataColumn[] { dtOracleStock.Columns["PkID001"] }; //Oracle Database
While Doing this,
dsStockMaster.Merge(StkFrmOracle); DataSet dsDiff = dsStockMaster.GetChanges();
It raises this DataException : Mismatch columns in the PrimaryKey : .PkID001 versus .PKID001.
Posted 4-Dec-12 20:39pm
Krunal Rohit 5-Dec-12 3:25am
use same datatype for PK in both DB...
Singh.pankaj 5-Dec-12 4:22am
string QryForSupp = " Select col1 as PkID001 from ABC ";

SqlDataAdapter SqlDAforSupp = new SqlDataAdapter(QryForSupp, Con);
DataSet dsStockMaster = new DataSet();
DataTable OrgStockMaster = dsStockMaster.Tables[0];

OrgStockMaster.PrimaryKey = new DataColumn[] { OrgStockMaster.Columns["PkID001"] };

if (oraConn.State != System.Data.ConnectionState.Open)

string checkQry = "SELECT col1 as PkID001 FROM AAA ";

DataSet StkFrmOracle = new DataSet();
OleDbCommand cmdStockMast = new OleDbCommand();
cmdStockMast.CommandText = checkQry;
cmdStockMast.CommandType = CommandType.Text;
cmdStockMast.Connection = oraConn;
OleDbDataAdapter odaForStock = new OleDbDataAdapter(cmdStockMast);

DataTable dtOracleStock = StkFrmOracle.Tables[0];

dtOracleStock.PrimaryKey = new DataColumn[] { dtOracleStock.Columns["PkID001"] };

dsStockMaster.Merge(StkFrmOracle); //This line is throwing Exception.
DataSet dsDiff = dsStockMaster.GetChanges();
My Oracle Column is of Data Type "varchar2", while SQL Column is "Varchar".
I think this is why I'm getting exception.
Krunal Rohit 5-Dec-12 4:25am
Ya thats why I've told you to change Table Definition..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170915.1 | Last Updated 5 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100