This is a migrated thread and some comments may be shown as answers.

I have error "Unable to establish a connection to the database. Please, verify that your connect..." when I'm deploy my website

11 Answers 1158 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jadesada
Top achievements
Rank 1
Jadesada asked on 01 Dec 2011, 08:56 AM
Hello I have a problem when I deploy my website but when I run in localhost it's didn't have a problem.

Error is show in picture "capture002.png"

I use MySql as database.

My code on "web.config" is

<?xml version="1.0"?>
<configuration>
    <connectionStrings>
        <add name="timesheet" connectionString="server=localhost;User Id=xx;password=xxxxxxxxxx;Persist Security Info=True;database=testDB" providerName="MySql.Data.MySqlClient"/>
    </connectionStrings>
    <appSettings>
        <add key="Telerik.ScriptManager.TelerikCdn" value="Disabled"/>
        <add key="Telerik.StyleSheetManager.TelerikCdn" value="Disabled"/>
    </appSettings>
    <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
            <assemblies>
                <add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="Telerik.ReportViewer.WebForms, Version=4.2.10.1110, Culture=neutral, PublicKeyToken=A9D7983DFCC261BE"/>
                <add assembly="Telerik.Reporting, Version=4.2.10.1110, Culture=neutral, PublicKeyToken=A9D7983DFCC261BE"/>
                <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            </assemblies>
            <buildProviders>
                <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
            </buildProviders>
        </compilation>
        <pages>
            <controls>
                <add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI"/>
            </controls>
        </pages>
        <httpHandlers>
            <add path="ChartImage.axd" verb="*" type="Telerik.Web.UI.ChartHttpHandler" validate="false"/>
            <add path="Telerik.Web.UI.SpellCheckHandler.axd" verb="*" type="Telerik.Web.UI.SpellCheckHandler" validate="false"/>
            <add path="Telerik.Web.UI.DialogHandler.aspx" verb="*" type="Telerik.Web.UI.DialogHandler" validate="false"/>
            <add path="Telerik.RadUploadProgressHandler.ashx" verb="*" type="Telerik.Web.UI.RadUploadProgressHandler" validate="false"/>
            <add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource" validate="false"/>
            <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>
            <add path="Telerik.ReportViewer.axd" verb="*" type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=4.2.10.1110, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" validate="true"/>
        </httpHandlers>
        <httpModules>
            <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule"/>
            <add name="RadCompression" type="Telerik.Web.UI.RadCompression"/>
        </httpModules>
    </system.web>
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules runAllManagedModulesForAllRequests="true">
            <remove name="RadUploadModule"/>
            <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule" preCondition="integratedMode"/>
            <remove name="RadCompression"/>
            <add name="RadCompression" type="Telerik.Web.UI.RadCompression" preCondition="integratedMode"/>
        </modules>
        <handlers>
            <remove name="ChartImage_axd"/>
            <add name="ChartImage_axd" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" preCondition="integratedMode"/>
            <remove name="Telerik_Web_UI_SpellCheckHandler_axd"/>
            <add name="Telerik_Web_UI_SpellCheckHandler_axd" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" preCondition="integratedMode"/>
            <remove name="Telerik_Web_UI_DialogHandler_aspx"/>
            <add name="Telerik_Web_UI_DialogHandler_aspx" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" preCondition="integratedMode"/>
            <remove name="Telerik_RadUploadProgressHandler_ashx"/>
            <add name="Telerik_RadUploadProgressHandler_ashx" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" preCondition="integratedMode"/>
            <remove name="Telerik_Web_UI_WebResource_axd"/>
            <add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" preCondition="integratedMode"/>
            <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
            <add name="Telerik.ReportViewer.axd_*" path="Telerik.ReportViewer.axd" verb="*" type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=4.2.10.1110, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" preCondition="integratedMode"/>
        </handlers>
    </system.webServer>
</configuration>


If you want any information to analyse this problem please tell me.

Thank you for help,
Jo

11 Answers, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 02 Dec 2011, 04:53 PM
Hi Jadesada,

This does not seem like a problem related to Telerik Reporting itself, but rather an issue with connection configurations. If you report is in a separate project (ClassLibrary) make sure that you have copied the connection string from the app.config in the ClassLibrary to the web.config in the Website.

Greetings,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Ed Staffin
Top achievements
Rank 1
answered on 08 Jun 2013, 04:03 PM
Brutal! Now  you tell me!
I wasted a hour or two because I needed to copy the connection string.
At least that fixes the problem!
Thanks ... Ed

0
Swapna
Top achievements
Rank 1
answered on 29 Apr 2014, 02:56 PM
Hi, i'm facing the same issue...not able to display mysql report in the view. Its says "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 -------------
Format of the initialization string does not conform to specification starting at index 0."

I updated the same connection string from the class library but no luck. I still get the same issue.
Any help is appreciated.
0
Harika
Top achievements
Rank 1
answered on 30 Apr 2014, 02:58 PM
In your web application web.config file, add the connection string. Have them copied from your app.config file of your reports project just to have name consistency.
0
Swapna
Top achievements
Rank 1
answered on 30 Apr 2014, 06:40 PM
I tried copying the connection string from app.config to web.config...but still facing the same issue.
0
Harika
Top achievements
Rank 1
answered on 30 Apr 2014, 07:22 PM
In your report code-behind file, make sure you are using the ConnectionString name you find in designer file. You should see something as below in your designer file. In this, SubroReports is the name of my project and NEWSUBRODEV is how I named my connectionstring.


SubroReports.Properties.Settings.NEWSUBRODEV
0
Swapna
Top achievements
Rank 1
answered on 30 Apr 2014, 07:47 PM
Thankyou Harrika..... now i don't get the "Unable to establish a connection to the database" issue...report viewer is displayed with no data.....any ideas what the issue can be....

Thank you so much in advance!
0
Harika
Top achievements
Rank 1
answered on 30 Apr 2014, 08:09 PM
In the properties window of your report, add a new binding for datasource and call the below mentioned method from the expression  like ChangeConnectionString (ReportItem, your connection string)


public static SqlDataSource ChangeConnectionString(object reportItem, string parameterConnectionString)
{
var report = (reportItem as Telerik.Reporting.Processing.Report);
var dataSource = (Telerik.Reporting.SqlDataSource)report.DataSource;
dataSource.ConnectionString = parameterConnectionString;
return dataSource;
}
0
Swapna
Top achievements
Rank 1
answered on 01 May 2014, 02:28 PM
Thank you Harika.....i tried creating a new page and added the report to the report viewer and its working fine now.

Thanks a lot for your help.
0
MG-Hakan
Top achievements
Rank 1
answered on 10 Aug 2014, 12:37 PM
What if we have more than one SqlDataSources in a report object?
0
Stef
Telerik team
answered on 11 Aug 2014, 11:51 AM
Hi Gokhan,

You can use the approach illustrated in the code snippets of the Changing the connection string dynamically according to runtime data KB article. All data items in the report are iterated and their DataSource is modified.


I hope this information helps you.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Jadesada
Top achievements
Rank 1
Answers by
Elian
Telerik team
Ed Staffin
Top achievements
Rank 1
Swapna
Top achievements
Rank 1
Harika
Top achievements
Rank 1
MG-Hakan
Top achievements
Rank 1
Stef
Telerik team
Share this question
or