Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I get en error when i set System.Data.DataTable to DataSet1.Tables the error is "Cannot convert type 'System.Data.DataTable' to 'WindowsFormsApplication1.DataSet1'"..

I want to create a Crystal report without database fields with my custom fields(Don't want Data.DataSet)...

My Code is -:
C#
DataSet1 ds1 = new DataSet1();                        
            OleDbConnection con=new OleDbConnection("Provider=Microsoft.jet.oledb.4.0; data source="+Application.StartupPath+@"\DataInfo1.mdb");           
            con.Open();
           OleDbDataAdapter da=new OleDbDataAdapter(@"SELECT ct.custID, c.custName, c.custAdd, ct.custTranDate, ct.custTranType, ct.custPaidAmt, ct.custDueAmt, c.custArea FROM custTransaction AS ct LEFT JOIN custDetails AS c ON ct.custID = c.custID WHERE ct.custID='CUST-000002' and ct.custTranDate BETWEEN #2/28/13# AND #3/1/13#;",con);
           DataSet ds = new DataSet();
           DataTable dt = new DataTable();
           da.Fill(dt);           
           ds1 = dt; //Error is here
//           MessageBox.Show(ds1.Tables[0].Rows.Count.ToString());
           CrystalReport2 cr = new CrystalReport2();
           cr.SetDataSource(ds1);           
            this.crystalReportViewer1.ReportSource =cr;
            this.crystalReportViewer1.Show();


Thanks in Advance....
Posted
Comments
Savalia Manoj M 7-Mar-13 7:50am    
In your code you write DataSet1(). What is it??
JayantaChatterjee 7-Mar-13 8:03am    
I added DataSet1 from Project - Add New Item Dialogue Box and select DataSet from the List(default name is DataSet1.xsd)...
Select DataSet1.xsd from Solution Explorer and right click . Select datatable from the menu then Right click the datatable and select Add-Column . that's the way I create DataSet1 and his fields..

1 solution

A DataTable and a DataSet are different types, you cannot use an expression such as you have coded. Go to MSDN and read the documentation for each class.
 
Share this answer
 
Comments
JayantaChatterjee 7-Mar-13 8:10am    
Sir, I know that's different types,
but is there any way to assign the all tables with rows from Data.DataSet to the DataSet1??
Richard MacCutchan 7-Mar-13 8:17am    
A quick check of the documentation reveals the answer.
JayantaChatterjee 7-Mar-13 8:25am    
Thanks Sir....
I solve the problem.. :-)

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