Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
<target>.Renewal_Start and .Renewal_Start have conflicting properties: DataType property mismatch.

im facing the error like this


C#
ReportDocument rptDoc = new ReportDocument();
   DataSet1 ds1 = new DataSet1(); // .xsd file name
   DataTable dt = new DataTable();

   // Just set the name of data table
   dt.TableName = "bill";
   dt = getAllOrders(); //This function is located below this function
   ds1.Tables[0].Merge(dt);<<<<<<getting error here : .column1 and .column1 have conflicting properties: DataType property mismatch.>>>>>>>

   // Your .rpt file path will be below
   rptDoc.Load(Server.MapPath("../WebSite2/CrystalReport.rpt"));

   //set dataset to the report viewer.
   rptDoc.SetDataSource(ds1);
   CrystalReportViewer1.ReportSource = rptDoc;



public DataTable getAllOrders()
   {
       //Connection string replace 'databaseservername' with your db server name
       string sqlCon = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Apps\WebSite2\Database21.accdb;Persist Security Info=False;";
       OleDbConnection Con = new OleDbConnection(sqlCon);
       OleDbCommand cmd = new OleDbCommand();
       DataSet ds = null;
       OleDbDataAdapter adapter;
       try
       {
           Con.Open();
           cmd = Con.CreateCommand();
           cmd.CommandType = CommandType.Text;
           cmd.CommandText = "select *from bill";
           ds = new DataSet();
           adapter = new OleDbDataAdapter(cmd);
           adapter.Fill(ds, "bill");
           cmd.ExecuteNonQuery();
       }

}
Posted
Updated 16-Jul-12 1:30am
v2

for ds1.Tables[0].Merge(dt); to work both the datatables have to be union compatible i.e. both of the should contain same number of columns and the respective columns should be of same datatype in each table.

Please ensure that both the datatables conform to this requirement and it will work fine.
 
Share this answer
 
Please check your DataTables that they exists same number of columns.

Thanks
Ashish
 
Share this answer
 
Comments
Rahul Rajat Singh 16-Jul-12 8:02am    
+4 for the answer. would have given 5 if you would have mentioned that the datatype of respective columns should also match.
AshishChaudha 16-Jul-12 8:03am    
Thanks Rahul...Sorry for my mistake..
better to use join statement and make view before using it in dataset
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900