Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WinForm dataset
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");           
            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 7-Mar-13 2:37am
Comments
Savalia Manoj M at 7-Mar-13 7:50am
   
In your code you write DataSet1(). What is it??
Jayanta Chatterjee at 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
good
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.
  Permalink  
Comments
Jayanta Chatterjee at 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 at 7-Mar-13 8:17am
   
A quick check of the documentation reveals the answer.
Jayanta Chatterjee at 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
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,142
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 7 Mar 2013
Copyright © CodeProject, 1999-2014
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