Click here to Skip to main content
13,045,790 members (44,512 online)
Rate this:
Please Sign up or sign in to vote.
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 -:
DataSet1 ds1 = new DataSet1();                        
            OleDbConnection con=new OleDbConnection("Provider=Microsoft.jet.oledb.4.0; data source="+Application.StartupPath+@"\DataInfo1.mdb");           
           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();
           ds1 = dt; //Error is here
//           MessageBox.Show(ds1.Tables[0].Rows.Count.ToString());
           CrystalReport2 cr = new CrystalReport2();
            this.crystalReportViewer1.ReportSource =cr;

Thanks in Advance....
Posted 7-Mar-13 1:37am
Savalia Manoj M 7-Mar-13 7:50am
In your code you write DataSet1(). What is it??
Jayanta Chatterjee 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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Jayanta Chatterjee 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.
Jayanta Chatterjee 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 7 Mar 2013
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