locked
Crystal Report Asking for Database Authentication each time when I view Page. RRS feed

  • Question

  • User-2075946749 posted

    Whenever I open my Crystal Report page, I am taken to the Database Authentication page where I am asked for

    User name
    Data Name
    Password

    each time.

    Is there a way to avoid this and I save these authentication in my page once.

    I am using VS2005, C#.

    Any Help will be appriciated.

    Thanks
    Asif

    Wednesday, January 16, 2008 8:01 AM

Answers

  • User2036640569 posted

     Asif,

    Please check once again whether you have given the user credentials both while designing the crystal report and in the code. AFAIK it should work. The logon credentials which you give in the wizards should also match the logon credentials in your code. Check Once.

     

    if my post helped you please MARK AS ANSWER 

    Sreekanth 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 18, 2008 4:50 AM

All replies

  • User-1509636757 posted

    did you use Typed DataSet to generate Crystal Report ??

    if so, then make sure that the Name or the DataTable in "Typed DataSet" and the Name DataTable that you assign as "RecordSource" to crystal reprort must be same...

    hope it helps./. 

    Wednesday, January 16, 2008 8:11 AM
  • User-2075946749 posted

    Hi Kaushalparik27, 

    I  used "Field Explorer window" to create Ole Db (ADO) Connection.
    and I provided all information Server Name, ID, Password and DB name during the connection Creation Process.
    but when I open the crystal report page. It ask all these info again.
    It is anoying to enter this information again and again.
    any solution that we save this information some where during connection creation once.
    and we don't need to enter it again and again while accessing the crystal report pages.
     

    Thursday, January 17, 2008 3:58 AM
  • User2036640569 posted

    Hi Asif,

    Set the logon information in you code as shown below. Use this code approach instead.

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;

    public partial class _Default : System.Web.UI.Page
    {
        private ReportDocument rpt;

        private void Page_Init(object sender, EventArgs e)
        {
            ConfigureCrystalReports();
        }
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        private void ConfigureCrystalReports()
        {
            rpt= new ReportDocument();
            string reportPath = Server.MapPath("youreportname.rpt");
            rpt.Load(reportPath);
            ConnectionInfo connectionInfo = new ConnectionInfo();
            connectionInfo.DatabaseName = "Northwind";
            connectionInfo.UserID = "user";
            connectionInfo.Password="user123";
            SetDBLogonForReport(connectionInfo,rpt);
            CrystalReportViewer1.ReportSource = rpt;
        }
        private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
        {
            Tables tables = reportDocument.Database.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
            {
                TableLogOnInfo tableLogonInfo = table.LogOnInfo;
                tableLogonInfo.ConnectionInfo = connectionInfo;
                table.ApplyLogOnInfo(tableLogonInfo);
            }
        }
    }
     

    If my post helped you please MARK AS ANSWER. 

    Regards
    Sreekanth..

    Thursday, January 17, 2008 7:20 AM
  • User-2075946749 posted

     I also used Typed Dataset. but could not solve the problem.

    I am beginner to asp.net so guide me in details.

     

     

    Thursday, January 17, 2008 8:24 AM
  • User2036640569 posted

    HI Asif,

    Even though You have included the logon information when creating the connection(in wizards) you also have to provide the logon information in your code. As u are using vs 2005 which uses crystal reports 10 a logon screen is automatically displayed. If u would have used crystal reports in vs 2003 an exception would have raised. So to get rid of the login screen include the user id and [password in your code as well as I have shown you in the code sample above.

    If my post helped you please MARK AS ANSWER 

     Thanks and Regards,

    Srikanth.
     

    Thursday, January 17, 2008 8:32 AM
  • User-2075946749 posted

     Hello Srikanth,

    I did exactly as you mentioned above.

    but Login screen is still asking for the details except one change that now I can see the user ID in my User ID field. but other fields (db name, password) are still showing empty, Although I added the information correctly in the code.

    Please Advise what is the Possible problem and how can i fix it.

     Thanks so much for you help

    Asif
     

    .

     

    Friday, January 18, 2008 3:50 AM
  • User2036640569 posted

     Asif,

    Please check once again whether you have given the user credentials both while designing the crystal report and in the code. AFAIK it should work. The logon credentials which you give in the wizards should also match the logon credentials in your code. Check Once.

     

    if my post helped you please MARK AS ANSWER 

    Sreekanth 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 18, 2008 4:50 AM
  • User-2075946749 posted

     Sreekanth,

    Thanks very much for your prompt reply.

    My problem is Solved (using Ole Db connection and Crystal report) by using ur code.

    But Still there is something in which you can help me.

    I am trying to do this by  Typed DataSet(using existing connection in my Web.config ConnectionString) and it does not work with the DataSet. Same problem asking for the authentication....

    Can you guide me in this case.

    Because I want to use my existing project's db connection which is in my web.config file for reports to avoid repeating.

    Thanks in advance.

    Asif


     

     

    Friday, January 18, 2008 5:50 AM
  • User2036640569 posted

     HI Asif,

    Instead of binding the dataset try binding the DataTable it should work. I did this and it worked for me.

     

    If my post helped you please MARK AS ANSWER 

     

    Regards,

    Sreekanth Reddy. L 

     

    Friday, January 18, 2008 6:07 AM
  • User-1509636757 posted

    I am trying to do this by  Typed DataSet(using existing connection in my Web.config ConnectionString) and it does not work with the DataSet. Same problem asking for the authentication....
     

    did you assign same DataSet in.. rdReportDocument.SetDataSource(dsDataSet);

    Creating Crystal Reports using C# with Datasets

    Friday, January 18, 2008 6:15 AM
  • User-2075946749 posted

    Hi Kaushalparik, 

    I am using  VS 2005 C#.

    The link you sent is in not for VS 2005.

    I am having problem.

    DBConnection DBConn = new DBConnection();
    OleDbDataAdapter myDataAdapter = DBConn.getDataFromDB();

    How can i use my how DB String which is in Web.config file.

    Thanks

    Asif 

    Friday, January 18, 2008 8:21 AM
  • User-317188563 posted

    hello Dear

    i tried to use your code

    it works fine if i run the website from the VS.net

    but when i run it over IIS i doesn't work and requiers the servername dbname username and password !

    this sound strange to me !

    i mean why does it work fine on VS.net while it doesn't when i run the website over IIS !!

    Please advice

    Sunday, February 3, 2008 3:15 AM
  • User485681933 posted

    The code behind code was exactly what I needed. Thank you.

    Wednesday, September 23, 2009 3:21 PM
  • User962328058 posted

    Use 'Microsoft OLE DB provider for SQL server'. Do not use 'SQL Native Client'. Database login by programatically is working fine for me after publishing also with 'Microsoft OLE DB provider for SQL server'.

    Friday, August 20, 2010 3:32 AM
  • User823773895 posted

    You are really a good developer who is solving the problems of other

    Tuesday, September 28, 2010 3:23 AM
  • User-1007744552 posted

    Guys i tried this in my app.config file in my project and it did work

    <startup useLegacyV2RuntimeActivationPolicy =" true ">
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
        </startup >

    Thursday, November 24, 2011 4:47 PM
  • User1196771204 posted

    hi sudani,

    have you managed to convert the application pool of your site to ASP.NET 4.0? Please be advised that if you are using Crystal Report for VS 2010 (v13), the reports need to be run on ASP.NET 4.0 framework.

    For Crystal Report 2010 (v13) hosting with ASP.NET 4.0 support, you can contact asphostcentral.com. Hope this helps.

    Thanks heaps! 

    Sunday, November 27, 2011 10:52 PM