Converting a Crystal Report from direct database access to using a Dataset
-
Monday, November 29, 2010 2:39 AM
I have many reports created in Crystal Reports. Their data sources are various Access tables. I connect to them like this:
CRViewer.ReportSource = Report Report.RecordSelectionFormula = mstrReportSQL CrTables = Report.Database.Tables For Each CrTable In CrTables CrTable.Location = sDatabase Next CRViewer.Show()
I want to change these reports to use a Dataset as their record source. That will allow me to change my database from Access to MS SQLCE.
Not sure where to start. Any tips would be appreciated...or better ideas.
Thanks.
All Replies
-
Monday, November 29, 2010 8:57 AMModerator
Hi Allen,
Welcome to MSDN forums.
You can refer here: http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-without-database.htm
but it writed by C#
You can use ADO.net to connect your database and retrieve records, you may refer here: http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson01.aspx
Hope these helps, if you have any problems, please feel free to let me know.Best Regards,
Alan Chen
________________________________________
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
Monday, November 29, 2010 1:21 PM
I did something similar where I replaced the CrTable and For Each above and set the report to use a dataset like:
Report.DataSource = myDataSetWhen I do this, I am prompted for login information. Not sure why I am getting a login prompt for a dataset.
-
Wednesday, December 01, 2010 8:32 AMModerator
Hi Allen34,
You can use ADO.net to get a dataset, like
string queryString = "SELECT CustomerID, CompanyName FROM dbo.Customers"; SqlDataAdapter adapter = new SqlDataAdapter(queryString, connection); DataSet customers = new DataSet(); adapter.Fill(customers, "Customers");
http://msdn.microsoft.com/en-us/library/bh8kx08z.aspx
CrystalReport1 objRpt = new CrystalReport1(); objRpt.SetDataSource(customers.Tables[1]); crystalReportViewer1.ReportSource = objRpt; crystalReportViewer1.Refresh();
Hope these helps, if you have any problems, please feel free to let me know.Best Regards,
Alan Chen
________________________________________
Please remember to mark the replies as answers if they help and unmark them if they provide no help- Marked As Answer by Allen34 Wednesday, December 01, 2010 1:52 PM

