Crystal report - Running thru .NET - c#

I created a crystal report using test a DB. I run the report using .NET ReportDocument class. Everything works fine until I connect to the test DB.
When same report is pointed to UAT DB (all required DB objects are available in UAT too), I am getting error. To fix this, I have to change the server name to UAT DB manually in the RPT file.
How to fix this?

A solution is to create a system DSN (ODBC) for connecting to your target database. You can then switch the ODBC to whichever database you want (local,test,stage etc). Also, if you ensure an ODBC connection of the same name is available on all your servers, moving the report from dev->test->stage->production should be easy.

Using push reports should solve your issue. You can set up the report to accept a strongly-typed ADO.NET Dataset, and supply that dataset at runtime.

Isn't that how it's supposed to work? It has to know to what DB it's connecting?
Maybe I'm missing something but it sounds like you just needed to get the connection right.

Related

Error 28P01 - Password authentication failed

recently I have started my adventure with databases.
I have managed to install postgreSQL and create simple database.
I've tried to create simple app which will allow me to view data from DB.
I'm using VS 2017. I have managed to configure DataSource in my WindowsForm (NetFramework) project. Test connection was successful.
When I try to fill my ListBox with data from table I'm recieving error 28P01 (it seems to mean that I'm using wrong password / username).
It is impossible - im using default account (postgres) and passsword which allowed me to populate DB in datagrip.
Can anyone help me to understand what is going on?
Guys I have managed to work it out. The thing that I did bad was configuration of connection in VS DataSource configuration. I had choosen NOT to include sensitive data into connection string - I had to put it in my code or change setting to INCLUDE it.
I feel so dumb

How to create a crystal report with Firebird's Database

I am trying to build a desktop application. I need to create a report but I don't know how to do? I am using to use FireBird for my Database. I am using windows 8.1.
Of course I am not forget to googling, but I do not know what is wrong with my steps.
The following are the steps that I have tried to do :
download ODBC Driver from this link and install it.
download Firebird-2.5.5.26952-0_x64_embed.zip and extract it to path C:\Firebird-2.5.5.26952-0_x64_embed
Try to Add ODBC Data Source Administrator like this image
I try to test connection but I get an error Open Database C:\Users\User\Documents\FDB\TEST.GDB failed
Whats wrong with my steps?
I am new in c#.
The field Database have to be in following format:
:
for example:
127.0.0.1:c:\Databases\data.gdb

Crystal Reports for VS2010

I'm having some issues getting crystal reports working nicely with our applications. And i cannot seem to find any resources that answer my question.
Basically, we have a crystal report, designed in the crystal reports application with it's own datasource.
Now when i add this to VS and display it, i need to setup a connection on the PC using MYSQL ODBC Datasource configuration tool, however even with this datasource setup, the crystalreports viewer askes for a password, and even suppling the correct password will show a "login failed. please try again" error message.
Ideally what i would like to know, is
A) is it possible and if so how, can i setup the connection in VS2010 so that i wont need to go around using MYSQL ODBC Datasource configuration tool on every PC i deploy my application too.
B) why does this connection always fail, the credentials are correct (we've tested multiple times, and the report & connection function perfectly from within crystal reports)
Hopefully you guys can help me out, my google fu has failed me.
If the Crystal Report allows for the username and password to the mySQL stored procedure to be passed to the report through the ReportViewer object, you have to use .NET code-behind to set the credentials via the:
ReportViewer.ServerReport.ReportServerCredentials
property of the ReportViewer instance.
Here's an example:
System.Net.NetworkCredential networkCredentials =
new System.Net.NetworkCredential("username", "password", "domain");
reportViewer.ServerReport.ReportServerCredentials = networkCredentials;

How to Connect Crystal Reports to MySQL directly by C# code without DSN or a DataSet

How can I connect a Crystal Report (VS 2008 basic) to a MySQL DB without using a DSN or a preload DataSet using C#?
I need install the program on several places, so I must change the connection parameters. I don't want to create a DSN on every place, nor do I want to preload a DataSet and pass it to the report engine. I use nhibernate to access the database, so to create and fill the additional DS would take twice the work and additional maintenance later. I think the best option would be to let the crystal reports engine to connect to MySQL server by itself using ODBC.
I managed to create the connection in the report designer (VS2008) using the Database Expert, creating an ODBC(RDO) connection and entering this connection string
"DRIVER={MySQL ODBC 5.1 Driver};SERVER=myserver.mydomain"
and in the "Next" page filling the "User ID", "Password" and "Database" parameters. I didn't fill the "Server" parameter. It worked. As a matter of fact, if you use the former connection string, it doesn't matter what you put on the "Server" parameter, it seems the parameter is unused. On the other hand, if you use "DRIVER={MySQL ODBC 5.1 Driver}" as a connection string and later fill the "Server" parameter with the FQDN of the server, the connection doesn't work.
How can I do that by code? All the examples I've seen till now, use a DSN or the DataSet method. I saw the same question posted but for PostgreSQL and tried to adapt it to mysql, but so far, no success. The first method:
Rp.Load();
Rp.DataSourceConnections[0].SetConnection("DRIVER={MySQL ODBC 5.1 Driver};SERVER=myserver.mydomain", "database", "user", "pass");
Rp.ExportToDisk(ExportFormatType.PortableDocFormat, "report.pdf");
raise an CrystalDecisions.CrystalReports.Engine.LogOnException during ExportToDisk
Message="Logon failed.\nDetails: IM002:[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.\rError in File temporal file path.rpt:\nUnable to connect: incorrect log on parameters.
the InnerException is an System.Runtime.InteropServices.COMException with the same message and no InnerException
The "no default driver specified" makes me wonder if the server parameter is unused here too (see above). In that case: How can I specify the connection string?
I haven't tried the second method because it doesn't apply.
Does anybody know the solution?
I think it'll likely be quicker to generate the Dataset via nHibernate, or do a direct ADO.NET query, then trying to solve the issue.

Why does this OdbcConnection throw me a System.InvalidOperationException?

I am building a Winforms C# 2.0 application.
I have successfully been able to connect to my SLQ Server database using the following:
m_connexion = new SqlConnection("server=192.168.xxx.xxx;uid=...;pwd=...;database=...");
Because my company wanted to be able to use any database, I went on to use the Odbc driver and my commands went on like this:
m_connexion = new OdbcConnection("server=192.168.xxx.xxx;uid=...;pwd=...;database=...");
However, this throws out a System.InvalidOperationException. Any idea why?
I'm also trying to use a DSN, but the commend
OdbcConnection connection = new OdbcConnection("DSN=MyDataSourceName"); suggested here but it likewise throws my a System.InvalidOperationException
The connection string needs a Provider= so that the ODBC drivers know which server you're connecting to. In this case Provider=SQLSERVER I believe.
UPDATE: Should have been Provider=SQLOLEDB
I think you need to specify a driver. Look here for details: http://connectionstrings.com/sql-server-2005#21
If you specify a DSN, you have to configure the DSN using the ODBC control panel. It's called "Set up data sources (ODBC)" under Administrative Tools. The panel also has a "test" button, which might tell you more about what's going wrong.
P.S. Being "database independent" is much more work than using ODBC connection, command and datareader. You'd have to make sure your queries run on each target database, which you will not be able to do if you don't have a test server of each. So if I were you, I'd code it up using SqlConnection, since you already got that working.

Categories