locked
Crystal Report export need credential ..? RRS feed

  • Question

  • User-510633892 posted

    I am Using crystal report for reportig. In which i used to dataset xsd file for crystal report ado.net dataset. When report is loaded it is fine and as needed. but when i want to export that report it shows following screen. It need credential...
    I am not able to find any ans ....

    Can any body help me out...
    Thanks.... IMage screen

    Thursday, July 4, 2013 12:51 AM

Answers

  • User1428336426 posted

    Change like this

    if ((string)Session["ReportName"] == "InventoryPurchaseOrderDetail.rpt")
                {
                    PONo = (String)Session["PONo"];
                    if ((string)Session["Print"] == "true")
                    {
                        report.Load(path);
                    report.SetDatabaseLogon("user", "pass", "server", "DBName");
                    report.SetDataSource(BAL.Reports.Inventory_ReportBAL.getPurchaseOrderDetail(PONo).Tables[0]);
                        report.PrintToPrinter(1, false, 1, 1);
                    }
                }

                report.Load(path);
                report.SetDatabaseLogon("user", "pass", "server", "DBName");
                report.SetDataSource(BAL.Reports.Inventory_ReportBAL.getPurchaseOrderDetail(PONo).Tables[0]);
                CrystalReportViewer1.ReportSource = report;
                CrystalReportViewer1.DataBind();
                CrystalReportViewer1.RefreshReport();

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 4, 2013 4:39 AM
  • User-578610739 posted

    Hi Bhushan ,

    You need four entry in web.config for this.

    ConnectionInfo reportConnectionInfo = new ConnectionInfo();
    reportConnectionInfo.ServerName = ConfigurationManager.AppSetting["ServerName"];
    reportConnectionInfo.DatabaseName = ConfigurationManager.AppSetting["dbName"];
    reportConnectionInfo.UserID = ConfigurationManager.AppSetting["Uid"];
    reportConnectionInfo.Password = ConfigurationManager.AppSetting["pwd"];
    
    foreach (Table table in reportDocument.Database.Tables) {
      table.LogOnInfo.ConnectionInfo = reportConnectionInfo;
    }


    http://forums.asp.net/t/1086334.aspx/1

    http://stackoverflow.com/questions/2784836/using-a-connection-string-in-web-config-for-crystal-report

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 5, 2013 4:47 AM

All replies

  • User1428336426 posted

                    dsDetails.WriteXml(desktopFileName("Details.xsd"), XmlWriteMode.WriteSchema);
                    ReportDocument RptDoc = new ReportDocument();
                    RptDoc.Load(Server.MapPath(@"BRFormats\Word.rpt"));
                    RptDoc.SetDatabaseLogon("user", "pass", "server", "DBName");
                    RptDoc.SetDataSource(dsDetails);
                    CrystalReportViewer1.EnableDatabaseLogonPrompt = false;
                    CrystalReportViewer1.ReportSource = RptDoc;
                    CrystalReportViewer1.DataBind();

    Thursday, July 4, 2013 1:35 AM
  • User-1583800459 posted

    You can provide the database credential using the following:

    // rpt is the object of report document.
    rpt.SetDatabaseLogon("username", "password", "database location", "databasename");
    rpt.VerifyDatabase();
    
    crystalReportViewer1.ReportSource = rpt;
    crystalReportViewer1.RefreshReport();
    crystalReportViewer1.Refresh();
    
    

    And put all these things in app.config or web.config file to access and modify it in future as required.

    I hope it will help you. :)

    Thursday, July 4, 2013 1:39 AM
  • User-578610739 posted

    HI Bhusahn,

    As Neema said , please open your code menas give credential code while exprot even though each time you must assign that thing. So put your code outside of ispostback

    Thursday, July 4, 2013 1:39 AM
  • User-510633892 posted

    Hey Rima,
    Thanks for ur answer, it is excelent..... 

    But sorry to say that I am not able to get it.

    Do you mind to explain it for me ....

    Please....

    My code is

    if ((string)Session["ReportName"] == "InventoryPurchaseOrderDetail.rpt")
                {
                    PONo = (String)Session["PONo"];
                    if ((string)Session["Print"] == "true")
                    {
                        report.Load(path);
                    report.SetDataSource(BAL.Reports.Inventory_ReportBAL.getPurchaseOrderDetail(PONo).Tables[0]);
                        report.PrintToPrinter(1, false, 1, 1);
                    }   
                }
    
                report.Load(path);
                CrystalReportViewer1.ReportSource = report;
                CrystalReportViewer1.DataBind();
                CrystalReportViewer1.RefreshReport();

    PLease tell he where should i put n what ...

    One more Doubt,

    I am using Dataset xsd file which contasins table. That table is fill when report is called.

    So what should i give userid, password, Servername, database name

    Thank you...

    Thursday, July 4, 2013 3:55 AM
  • User1428336426 posted

    Change like this

    if ((string)Session["ReportName"] == "InventoryPurchaseOrderDetail.rpt")
                {
                    PONo = (String)Session["PONo"];
                    if ((string)Session["Print"] == "true")
                    {
                        report.Load(path);
                    report.SetDatabaseLogon("user", "pass", "server", "DBName");
                    report.SetDataSource(BAL.Reports.Inventory_ReportBAL.getPurchaseOrderDetail(PONo).Tables[0]);
                        report.PrintToPrinter(1, false, 1, 1);
                    }
                }

                report.Load(path);
                report.SetDatabaseLogon("user", "pass", "server", "DBName");
                report.SetDataSource(BAL.Reports.Inventory_ReportBAL.getPurchaseOrderDetail(PONo).Tables[0]);
                CrystalReportViewer1.ReportSource = report;
                CrystalReportViewer1.DataBind();
                CrystalReportViewer1.RefreshReport();

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 4, 2013 4:39 AM
  • User-510633892 posted

    So many many thanks.......
    One last doubt pls...
    How do i get the "user" "pass" "Server" "DBName" for filling this line...

    report.SetDatabaseLogon("user", "pass", "server", "DBName");

    Details of database i am using is SQL Server 2008 R2. Connection String is stored in the Web.config file. All is working fine.

    I am using dataset xsd file. When I am calling getPurchaseOrderDetail() method that time i am filling that datatable in the xsd file.

    Some more information as like before using dataset xsd file. I have problem like insted of user id pass servername page is asking for the stored procedure parameters on screen only....
    Please help me....

    Friday, July 5, 2013 4:20 AM
  • User1428336426 posted

    You may use the username password and other details from web.config file which is same to connect the DB

    Friday, July 5, 2013 4:43 AM
  • User-578610739 posted

    Hi Bhushan ,

    You need four entry in web.config for this.

    ConnectionInfo reportConnectionInfo = new ConnectionInfo();
    reportConnectionInfo.ServerName = ConfigurationManager.AppSetting["ServerName"];
    reportConnectionInfo.DatabaseName = ConfigurationManager.AppSetting["dbName"];
    reportConnectionInfo.UserID = ConfigurationManager.AppSetting["Uid"];
    reportConnectionInfo.Password = ConfigurationManager.AppSetting["pwd"];
    
    foreach (Table table in reportDocument.Database.Tables) {
      table.LogOnInfo.ConnectionInfo = reportConnectionInfo;
    }


    http://forums.asp.net/t/1086334.aspx/1

    http://stackoverflow.com/questions/2784836/using-a-connection-string-in-web-config-for-crystal-report

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 5, 2013 4:47 AM
  • User-510633892 posted

    Thank you every one for helping me...
    See you soon with new query....Tongue Out

    Monday, July 8, 2013 12:05 AM
  • User1428336426 posted

    You are always welcome

    Monday, July 8, 2013 1:52 AM
  • User-510633892 posted

    Thanks....Smile

    Thursday, July 11, 2013 10:20 AM