Crystal Report and Dataset - c#

I am trying to add a crystal report into VS 2015, connected to a DataSet.
I managed to add the reportViewer to a form, create a DataSet with my SQL database, configured the report viewer using the wizard as to take the "clients" table from the DataSet (DataSet contains multiple tables), but when I run the application, I only get the column names and no data, whilst there are at least 20 clients in the database.
Am I missing something?

Have you created a connection to your datasource? If not you can do that via odbc.then in your designer see if you can load the data.before even running your app.

Related

How do i work with a designed DataSet with C# in VisualStudio

I imported a Table in a Visual Studio DataSet, from my local connected MariaDB on my Server. As Example the Table is "T_Users".
Problem: How can i load the actual Data from the Database into the DataSet and access it in C#?
The Table
My actual code
Desired result:
MessageBox.Show(DataSet.T_Users.Rows[1].Email.ToString());
should print "test#gmail.com"

Getting Error while creating report through Report wizard. And Sql Database is on Godaddy's server

I am Using SQL Server Management 2012. And connected to my online database which is on Godaddy's server. I Create an windows application in c# and using visual studio 2012.
Used string constring = "Data Source=184.168.47.21;Initial Catalog=ROT;User Id=myusername;Password=mypassword;";
It works fine. Insert,update,delete all works fine.
But now i am creating report. For that i used Report Wizard -> New database ->new dataset -> New Connection -> Servername=184.168.47.21 , clicked on Use SQL server authentication , write Username, password, write or select database name = ROT , clicked on test connection and got message Test connection Succeeded.
In Short I create two files Named "Report1.rdlc" and "ROTDataSet.xsd".
I designed report completely and take a reportViewer1 for displaying Report1.rdlc.
** this.tbl_BookingTableAdapter.Fill(this.ROTDataSet.tbl_Booking,i);
this.reportViewer1.RefreshReport();**
above code is of button1_click event.And "i" is a integer parameter i am passing to it.
but when i click on this button it gives an error in file named "ROTDataSet.Designer.cs"
on line "this.Adapter.Fill(dataTable);"
Error says "SqlException was unhandled. Login failed for user 'myusername'."
Now Please tell me what i am doing wrong?
SqlConnection conn is working perfectly in application for select and insert query but it gives error in creating report. Even i can see my Table,Table adapter in .Xsd file.
go daddy doesnt support SSRS on shared hosting http://support.godaddy.com/help/article/6490/do-you-restrict-any-features-in-ms-sql-2008?isc=webxpa

ReportExecutionService add datasource?

Until now, I have been using ReportViewer.LocalReport to generate PDF outputs of locally embedded SSRS Reports, which use predefined datasources that get overridden in my C# application by run-time generated data...
// Set the DataSources
report.LocalReport.DataSources.Add(new ReportDataSource("MilkSolids", this.MilkSolidsTable));
report.LocalReport.DataSources.Add(new ReportDataSource("Ingredients", this.IngredientsTable));
The drawback of course, is that I have to use older versions of BIDS to design the report in. But now I have a new option of using a web reference from our SQL Server 2008 Report Server. This way, I could use BIDS 2008 to write my report in, and then make the report server do the rendering. This works like a charm for the pre-defined datasource; HOWEVER, I cannot find any information on how to override predefined datasources in the ReportExecutionService class.
Is this even possible?
If not, does anyone have another suggestion?

Edit Crystal Report 8.5 file in .Net c#

I've got 2 applications:
1. App to prepare data for reporting - C# (.Net 1.1)
2. App to display report - C++ (maybe)
First app send parameters such a report file name, report parameters to second app via command line. Then second app display prepared report.
Now I want to change some report fields. My code in 1st app:
ReportDocument rDoc = new ReportDocument();
rDoc.Load(#"D:\reports\report_1.rpt");
rDoc.Database.Tables[0].Location = "newDBName.schema.oldTableName";
rDoc.SaveAs(#"D:\reports\report_1_modif.rpt",ReportFileFormat.VSNetFileFormat);
I want to modify rpt file because I want to take data from the archive database.
"CrystalDecisions.CrystalReports.Engine" reference version is 9.1.5000.0.
So 2nd app can't use modified rpt file because of incompatible versions. 2nd app can work only with 8.5 file formats.
When I open rpt file in CR Developer I can manually change location and save in 8.5 file format. In this case 2nd program normally works with modified file.
So my question is: "How can I in .Net C# open rpt file 8.5, modify and save in 8.5 format with another name?". Maybe I should use some unmanaged code?
Crystal Reports 8.5 was released in 2001. .Net in 2002.
I solved problem. My approach:
In C# code we update set of synonyms in DB after every user click "show report". After update each synonym still has the same name but follows to another table in different database.
We modified CR 8.5 file by hands: a) changed connection type to OLE DB (Native SQL Client) because of ODBC layer don't support synonyms b) set synonyms as tables locations instead of full table names.
Task solved!
UPD. We need p2soledb.dll to use OLE DB.

DataSet used by ReportViewer doesn't use credentials from ConnectionString in App.Config

I have a Windows Forms app written in C#, and part of the app has a Reporting form using RDLC reports and a ReportViewer control.
In order to create the reports, for each report I first created a DataSet and added a TableAdapter to the DataSet. I used the TableAdapter wizard to specify the query for the report, and I selected a ConnectionString that was already defined in App.Config and is used elsewhere in the application.
Everything works fine on my development box, but when I move the app to production where the database password isn't the same as my dev box, the reports all fail to run with the exception that the 'sa' password is invalid.
Now, the password is set properly in the ConnectionString in app.config in production. I use this same ConnectionString everywhere else in the app, including to log in, so I know that the sa password is set properly.
It seems to me that when I add a TableAdapter to a DataSet using the wizard, and it asked me to choose a connection (which I chose the existing connection that was already in app.config and is used elsewhere in the app), it must be storing it somewhere and not always reading it from app.config. Or am I misunderstanding something?
I just want each DataSet with its TableAdapter to be able to use the connection string from app.config, which includes the username and password.
Does anyone know how to do that?
I hacked around this by doing the following before calling the Fill method on the TableAdapter...
this.EMPLOYEETableAdapter.Connection.ConnectionString =
ConfigurationManager.ConnectionStrings["MCLabor"].ToString();
This works. It's kind of lame though, and it definitely proves that when you create the TableAdapter using the wizard, and you select an existing connection from App.Config (from the Connections drop down box in the wizard), it doesn't actually load that connection string from app.config at runtime. Does anyone know why, or what the real way to handle this is? I don't like having to manually set the connection string for every TableAdapter for every DataSet for every report.

Categories

Resources