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

12 posts, 0 answers
  1. Jadesada
    Jadesada avatar
    8 posts
    Member since:
    Jun 2011

    Posted 01 Dec 2011 Link to this post

    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"?>
            <add name="timesheet" connectionString="server=localhost;User Id=xx;password=xxxxxxxxxx;Persist Security Info=True;database=testDB" providerName="MySql.Data.MySqlClient"/>
            <add key="Telerik.ScriptManager.TelerikCdn" value="Disabled"/>
            <add key="Telerik.StyleSheetManager.TelerikCdn" value="Disabled"/>
        <customErrors mode="Off"/>
        <compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
                    <add assembly="Microsoft.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                    <add assembly="Microsoft.ReportViewer.Common, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                    <add assembly="Microsoft.Build.Framework, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                    <add assembly="System.Management, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                    <add assembly="Telerik.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=A9D7983DFCC261BE"/>
                    <add assembly="Telerik.Reporting, Version=, Culture=neutral, PublicKeyToken=A9D7983DFCC261BE"/>
                    <add assembly="System.Design, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                    <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
                    <add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI"/>
                <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=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>
                <add path="Telerik.ReportViewer.axd" verb="*" type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" validate="true"/>
                <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule"/>
                <add name="RadCompression" type="Telerik.Web.UI.RadCompression"/>
            <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"/>
                <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=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
                <add name="Telerik.ReportViewer.axd_*" path="Telerik.ReportViewer.axd" verb="*" type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" preCondition="integratedMode"/>

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

    Thank you for help,
  2. Elian
    Elian avatar
    435 posts

    Posted 02 Dec 2011 Link to this post

    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.

    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!

  3. DevCraft banner
  4. Ed Staffin
    Ed Staffin avatar
    66 posts
    Member since:
    Nov 2008

    Posted 08 Jun 2013 Link to this post

    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

  5. Swapna
    Swapna avatar
    4 posts
    Member since:
    Apr 2014

    Posted 29 Apr 2014 Link to this post

    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.
  6. Harika
    Harika avatar
    9 posts
    Member since:
    Apr 2014

    Posted 30 Apr 2014 in reply to Swapna Link to this post

    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.
  7. Swapna
    Swapna avatar
    4 posts
    Member since:
    Apr 2014

    Posted 30 Apr 2014 Link to this post

    I tried copying the connection string from app.config to web.config...but still facing the same issue.
  8. Harika
    Harika avatar
    9 posts
    Member since:
    Apr 2014

    Posted 30 Apr 2014 in reply to Swapna Link to this post

    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.

  9. Swapna
    Swapna avatar
    4 posts
    Member since:
    Apr 2014

    Posted 30 Apr 2014 in reply to Harika Link to this post

    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!
  10. Harika
    Harika avatar
    9 posts
    Member since:
    Apr 2014

    Posted 30 Apr 2014 in reply to Swapna Link to this post

    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;
  11. Swapna
    Swapna avatar
    4 posts
    Member since:
    Apr 2014

    Posted 01 May 2014 Link to this post

    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.
  12. Gokhan
    Gokhan avatar
    3 posts
    Member since:
    Oct 2012

    Posted 10 Aug 2014 in reply to Harika Link to this post

    What if we have more than one SqlDataSources in a report object?
  13. Stef
    Stef avatar
    2933 posts

    Posted 11 Aug 2014 Link to this post

    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.


    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.

Back to Top
DevCraft banner