Telerik report not working - telerik

An error has occurred while processing Report 'ReportStandart': Unable to establish a connection to the database. Please, verify that your connection string is valid. In case you use a named connection string from the application configuration file, make sure the name is correct and the connection string settings are present in the configuration file of your application. ------------- InnerException ------------- !

Go to the folder where your report project is.
Open the folder and look for the file "Telerik.ReportDesigner.exe.config"
Open the file in Visual Studio and copy the connection string
Past the above connection string to your web.config
You can find the above here towards the end of the video (3':15'')

In this sample, we have got sqlDataSource by filling connection string:
MyReport report = new MyReport();
string selectCommand = #"SELECT * FROM Sales.Store";
string connectionString = "Data Source=(local)\\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=True";
Telerik.Reporting.SqlDataSource sqlDataSource = new Telerik.Reporting.SqlDataSource(connectionString, selectCommand);
report.DataSource = sqlDataSource;
In my case, my start-up project has connection string in its config file so I cannot use the connection string again in another project because of this error:
an error has occurred while processing table 'crosstab 1' ...
format of the initialization string does not conform to specification
starting at index 0
This error is because of having 1 more connection string.
Maybe this discussion on the Telerik site entitled Set CrossTab DataSource in code-behind will help.

Related

Configuration Manager returns default connection string

I've added the line
static private readonly string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings[0].ConnectionString;
to my Console App project, and it returns a connection string despite the fact that I haven't yet set one up, and there is no config file anywhere in the solution folder.
It appears to be an ASP.NET database connection string:
data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true
Where is VS getting this string from?
I think this has been answered in full here:
Autogenerated Default Connection
Essentially it's a default from Machine.Config.

Sql developer custom connection string

How to use custom connection string in Oracle sql developer to connect?
jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)
(HOST=147.22.109.218)(port=1521))(ADDRESS=(PROTOCOL=TCP)
(HOST=147.22.109.219)(port=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=147.22.109.220)(port=1521)))
(FAILOVER=on)(LOAD_BALANCE=on)
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=cmphpd)))
Please help. Thanks
To us a TNS connection string, in the New / Select Database Connection window where you configure the connection:
Set Connection Type to TNS
Under the Details tab select Connect Identifier
Put the connection string into the text box next to Connect Identifier
Click Test if you'd like, to make sure it works
Click Save
Similarly, under Connection Type there also seems to be an option for a custom JDBC URL if that's what you prefer.
(Instructions and screenshot from version 19.4, in case it makes a difference)
Try this:
jdbc:oracle:thin:#147.22.109.220:1521/cmphpd
These are the best and complete instructions I've found.
https://blogs.oracle.com/dev2dev/ssl-connection-to-oracle-db-using-jdbc,-tlsv12,-jks-or-oracle-wallets
Below are the steps which I took to fix this issue:
Install JCE (following the instructions in Readme) - JCE
Add below lines in build.gradle
System.setProperty('oracle.net.ssl_version', '1.2')
System.setProperty('oracle.net.ssl_cipher_suites', '(TLS_RSA_WITH_AES_256_CBC_SHA256)')
System.setProperty('oracle.net.tns_admin', './lib')
System.setProperty('oracle.net.ssl_server_dn_match', 'true')
Setup db connection like
String connString = "jdbc:oracle:thin:#(description=(address_list=
(address=(protocol=tcp)(port=1521)(host=prodHost)))
(connect_data=(INSTANCE_NAME=ORCL)))";
OracleDataSource ods = new OracleDataSource();
ods.setURL(connString);
ods.setUser("scott");
ods.setPassword("tiger");
Connection conn = ods.getConnection();

Umbraco - First run - connection string failed

I just downloaded Umraco (via Web Platform Installer).
It takes me to this web page:
How can I just select 'integrated security'?
That connection string is set to a blank database that exists. I have added 'IIS AppPool\DefaultAppPool' and 'IIS APPPOOL\UmbracoTest' as database owner. The next screen is like this Database configuration is invalid for connection string Data Source=.;Integrated Security=True;Initial Catalog=UmbracoTest:
That connection string is fine, I've used '.' datasource elsewhere with no problems (SQL Express).
Is there any way to get useful error messages?
How can I get this working?
Thanks.
I just ran into the same issue during an Umbraco 6.1.5 installation. My issue was the providerName being empty as suggested, so when I added:
providerName="System.Data.SqlClient"
I was able to install and upgrade my Umbraco 6.1.3 database. My full connection string is:
<add name="umbracoDbDSN" connectionString="server=72.18.**.***,1533;database=mydatabase;user id=emma;password=******" providerName="System.Data.SqlClient" />
The connection string is wrong, trust me :)
Instead of DataSource=. try DataSource=.\sqlexpress
Also ensure that the initial catalog=UmbracoTest is actually the correct name of the database.
Finally, since you are using an Umbraco 6.x version, the log files will be at ~App_Data/Logs but in this case they will just tell you much the same as the install screen, that an SqlException has occurred.
Edit:
Looking at the Umbraco source, the error you see is raised by the following code:
if (_configured == false ||
(string.IsNullOrEmpty(_connectionString) ||
string.IsNullOrEmpty(ProviderName)))
{
return new Result
{
Message =
"Database configuration is invalid. Please check
that the entered database exists and that the provided
username and password has write access to the
database.",
Success = false,
Percentage = "10"
};
}
So my assumption is that you are missing the Provider from your connection string. In your web.config file your connection should look like this:
I had the same issue. I fixed it by adding the IIS_IUSRS user to the Umbraco site directory with "Modify" rights as the setup process is trying to write to the web.config with your connection string. Hope this helps.

CR with visual studio 2010 logon box

We are using CR with Visual studio 2010 for our applicaton.
Following is the code which I am using for generating the report from collection of objects which I got from Webservice.
SampleReport report = new SampleReport();
report.SetDataSource(response.Items);
Then at WPF level, I am assigning report source to the viewer as follows.
this.reportViewer.ViewerCore.ReportSource = report;
Problem is it is asking me login credential. Which I believe interesting as All the information to generate the report is ready to be picked up from the collection assigned as datasource.
Let me know what these credential could be. or how to override the behaviour.
Note: The designer had designed the .rpt file from xml, that WCF service provided.
I have looked around in forums for solutions, they dont have much information except following :
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
CrystalDecisions.CrystalReports.Engine.Tables CrTables ;
crConnectionInfo.ServerName = "YOUR SERVER NAME";
crConnectionInfo.DatabaseName = "YOUR DATABASE NAME";
crConnectionInfo.UserID = "YOUR DATABASE USERNAME";
crConnectionInfo.Password = "YOUR DATABASE PASSWORD";
CrTables = report.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
The problem is, I can understand if I would be connecting to DB to get the data... But getting data from object collection should not require the credential.
I faced such a problem earlier. What I did to fix this:
In the Visual Studio designer make sure that the Crystal Report Viewer doesn't have a report source defined
In the Crystal Report designer open the Field Explorer and right click on Database Fields and make sure you have selected the correct database location using the Set Database location, also try the Log On or Off Server
This is part of the code to load the report:
rptDoc.Load("CrystalReport_Test.rpt")
rptDoc.SetDataSource(rptDataset)
CrystalReportViewer1.ReportSource = rptDoc
CrystalReportViewer1.RefreshReport()
Hope this helps.

How to use new database instance of each MSTest unit test run

I'm using MSTest under Visual Studio 2010 to test an ASP.NET MVC 3 project. I have a SQL Express 2005 DB that I'd like it to use and I want a fresh instance of the DB every time, copied from a template I've included in the project. Pretty standard requirements, I would have though, but I can't get this to work.
I've created a .testsettings file which enables deployment and my connection string looks like this:
<add name="MyDb" connectionString="Data Source=.\SQLEXPRESS2005;Database=MyDbTest;AttachDBFilename=|DataDirectory|MyDbTest.mdf;User Instance=true;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
The test runs OK the first time, but after that it fails with errors like this:
Test method ... threw exception: System.Data.DataException: An exception occurred while initializing the database. See the InnerException for details. ---> System.Data.EntityException: The underlying provider failed on Open.
---> System.Data.SqlClient.SqlException: Database '...\bin\Debug\MyDbTest.mdf' already exists. Choose a different database name. Cannot attach the file '...\Out\MyDbTest.mdf' as database 'MyDbTest'.
The accepted answer in this MSDN thead says to remove the "Database=" connection string parameter. However, if I do that it fails with this error:
Test method ... threw exception:
System.InvalidOperationException: Unable to complete operation. The supplied SqlConnection does not specify an initial catalog.
How do I get this to work?
So far I've come up with a hack to change the DB name at runtime, at test assembly initialization time. This requires a further hack - using Reflection to enable modifying the configuration at runtime (thanks to David Gardiner).
[TestClass]
public static class TestHelper
{
[AssemblyInitialize]
public static void AssemblyInit(TestContext context)
{
RandomizeDbName();
}
private static void RandomizeDbName()
{
// Get the DB connection string setting
var connStringSetting = ConfigurationManager.ConnectionStrings["TheDbSetting"];
// Hack it using Reflection to make it writeable
var readOnlyField = typeof(ConfigurationElement).GetField("_bReadOnly",
BindingFlags.Instance | BindingFlags.NonPublic);
readOnlyField.SetValue(connStringSetting, false);
// Randomize the DB name, so that SQL Express doesn't complain that it's already in use
connStringSetting.ConnectionString = connStringSetting.ConnectionString.Replace(
"Database=MyTestDb", "Database=MyTestDb_" + new Random().Next());
}
}
Edit: It's actually even a bit worse than this: I'm having to call TestHelper.RandomizeDbName() at the start of every test that requires a fresh DB, otherwise it gets data left over from previous tests.

Resources