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.
Related
I have an old system which generated me a database in .CDB extension (i run on Firebird-1.5.6.5026-0-Win32) and i can access this database in IBExpert to query and stuff. But i need to write an application in .NET (VS 2010 4.0 framaework) so i can read this database and access some of the data to insert into a table inside SQLServer.
I tried many things, changed the server version and other things but i now all i get is ''Cannot find fbembed.dll'' exception error while trying to open the connection. My FB server doesnt have this file since he uses the 'fbclient.dll' already.
Any thoughts on how to connect my application to this .CDB database?
(this firebird version is the same that the legacy system is running, so i used the 1.7RC firebird .net provider within this server)
The connection string used is:
<add name="FirebirdConnectionString" connectionString="User=SYSDBA;Password=masterkey;
Database=localhost:C:\temp\BD\ECLECTIC.CDB;DataSource=localhost;Port=3051;
Dialect=3;Charset=NONE;Role=;Connection lifetime=15; Pooling=false;
MinPoolSize=0; MaxPoolSize=50; Packet Size=8192; ServerType=1;"
providerName="FirebirdSql.Data.FirebirdClient"/>
Unless you really want to use Firebird embedded (which you don't as you also specify localhost), you should not specify ServerType=1, but either leave it out entirely or set ServerType=0.
As to your other problem you mention in the comments, I suggest you check if this solves it and otherwise create a new question with more information.
I Created an application in c# with Visual Studio 2008, and i'am using SQL Server 2012 for implement databases for the applications.
My Question is :
How can i create an installation that contains the database without using the atach databse method.
Please F1 ! F1 !
You can export a script that will create and populate the database with data. What is the setup tool you are using ?
Or you can make the C# app create the database and default data in the first launch. In both cases you have to make a script file to create/populate the database.
To export the SQL script
right click on the database name in the SQL server manager
tasks->script
in C# open the scrip file using StreamReader and read all the lines. Then using SqlCommand execute the script file. First you need to open connections to Master database as you do not have your database created yet. Then modify the connection string and replace the master database with your database name.
The connection string can be stored in the Application Settings and you can provide a settings dialog to modify it for simplicity make the default connection string connect to the localhost computer and your database name.
The following code modify a setting key names Setting1
MessageBox.Show(Properties.Settings.Default.Setting1);
Properties.Settings.Default.Setting1 = "New Value";
Properties.Settings.Default.Save();
You can also create a custom action in your installer (.msi) file - here's a link that tells you the steps to do that. adding link to example with C# - here
We are looking into replacing Crystal with SSRS.
I would like to know if it is at all possible to load the .rdl or .rdl.data file in C# and generate the report to a memory stream.
I have seen some examples using the LocalReport, but this seems to be part of either the WinForms or WebForms assemblies.
So what I would like to know is:
Is it possible to load the report from file as part of our service.
Can we then generate the report to a Stream (lets say a memory
stream)
Can I do this without using the WebForms/WinForms assemblies in my
service
Can we achieve this without using the webservice for SSRS
I'm not sure that this is an answer, but lets call it supporting material.
I have this code example from msdn that shows how you can do this by creating a service client and calling a given report as a PDF and saves it to file stream.
http://msdn.microsoft.com/en-us/library/reportexecution2005.reportexecutionservice.render.aspx
The problem I'm currently having is finding the correct client object to interact with after pointing VS to the SSRS service. The object I'm using to interact with the service is:
ReportExecutionServiceSoapClient rs = new ReportExecutionServiceSoapClient();
However, the interface doesn't match my code example. So this is a little closer, but not an answer.
UPDATE: The correct Proxy class generator
Here's the link to how to generate the proxy correctly. You'll need the windows sdk installed (current is 7.1). You can find that on microsoft.com, like I did. Execute the command line and it'll generate a file for you. Include in project:
http://msdn.microsoft.com/en-us/library/ms155134%28v=SQL.110%29.aspx
UPDATE: Got the thing workin
I just had to generate the correct proxy. Ok, so for SSRS 2010, apparently they split report execution and management out into two services. The only one I needed to generate my report from a C# console app was the execution service. Maybe that's totally obvious to everyone but me :) ?
Ok so open up a Windows SDK command shell and put this stuff in it for the execution service:
wsdl /language:CS /n:"Microsoft.SqlServer.ReportExecution" http://<Server Name>/reportserver/reportexecution2010.asmx?wsdl /o:"ReportExecution.cs"
Go to C:\Program Files\Microsoft SDKs\Windows\v7.1 and pick up your ReportExecution.cs file. Copy and paste it in your project.
Then you just have to say this:
Microsoft.SqlServer.ReportExecution.ReportExecutionService rsExec =
new Microsoft.SqlServer.ReportExecution.ReportExecutionService();
rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
rsExec.Url = #"http://<ServerName>/reportserver/ReportExecution2005.asmx";
Follow along the example from this link, which is the same one as above, and you should be generating some pretty awesome reports from your handy C# app.
i created a application with function export report as pdf file, the application can download the report in web format.
i run the application in my pc, it is work, but i try run at user pc, but fail when exporting
Using _report
_report.Load(HttpContext.Current.Server.MapPath("Report/" & "report.rpt"))
_reportname = name & date.now
_report.ParameterFields("name").CurrentValues.Clear()
_report.ParameterFields("name").CurrentValues.AddValue(_name)
_report.SetDatabaseLogon(_gstrID, _gstrPassword, _gstrDataSource, _gstrCatalog)
_report.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, context.Response, True, _reportname)
_report.Export()
_report.Database.Dispose()
_report.Dispose()
any miss take in my code???
There are many things that could be happening here.
First, test it from a completely different computer that the two you have. Test it on the same computer with the problem using a different browser. Optionally, update your version of Adobe Reader on the misbehaving machine and try again.
Next, if you are using IIS 7.5 there is a hotfix concerning downloading PDF files ( http://support.microsoft.com/kb/979543 ) that impacts particular versions of the Adobe PDF Reader plug-in.
i want to open notepad, word or excel files from sql server using some query. is this possible? or is it possbile using C#.NET winform application. ? also, i want sql to use dll files present it my hard drive. how do i do both these tasks? please help me out with the code as well.
EDIT:
i have a .net winform application which accessess sql server database & is used to insert data in the database.
i want that when a user deletes a new record from a table in the database, & clicks the DELETE button on the Form, then the deleted data is exported to an excel file and the file is immediately opened.
is this possible?
for the export i would use bcp utility, but how to open the file ?
You can use XP_cmdshell to execute a process from within MS SQL server.
http://msdn.microsoft.com/en-us/library/ms175046.aspx
I don't think you'll see the application actually open/run because MSSQL runs as a service and services have their own desktop that you can't see. You'll see the process running in task manager's processes tab however.
You can also excute other processes from a GUI application using the System.Diagnostics.Process class
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
also, i want sql to use dll files
present it my hard drive
I don't understand this part. Please explain clearly what it is you're trying to do. What these dll files are and what they do and who created them. On the face of it I'd say no you can do this. But more importantly, I'd suggest you re-think the design of your application.
You can do it in .NET, using code like this:
VB.NET
Dim ps As New ProcessStartInfo
ps.UseShellExecute = True
ps.FileName = fileName
Process.Start(ps)
C#.NET
ProcessStartInfo ps = new ProcessStartInfo();
ps.FileName = filename;
Process.Start(ps);
I use it to open an Excel file I've just created. Should work just as well with other file types (assuming the proper program is installed).