Click here to Skip to main content
15,896,383 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i am putting single table in data set and running crystal reports then it's working finely but when i have multiple tables in data set then report viewer asking for username and password and i am passing exact user name and password as passed in connection String at web.config file but it's keep asking me that and not rendering any report on browser so, i wan't to know about this problem,can any one help me for that???please.......................
Connectionstring is.

<add name="crm_masterConnectionString" connectionString="server=localhost;user id=root;password=root@123;persistsecurityinfo=true;database=crm_master"
     providerName="MySql.Data.MySqlClient" />


the code is

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using MySql.Data.MySqlClient;
using CrystalDecisions;
using CrystalDecisions.CrystalReports;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

namespace CRM_And_Quotation_System
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        string CS = ConfigurationManager.ConnectionStrings["crm_masterConnectionString"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {
                CrystalReportViewer1.Visible = true;
                MySqlConnection connection = new MySqlConnection(CS);
                MySqlConnection connection1 = new MySqlConnection(CS);
                MySqlCommand command = new MySqlCommand("Select QuotationId,RexrothpartNo,Desccription,Price,Quantity,LineTotal From finalquotation where QuotationId=(select max(QuotationId) From finalquotation)", connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(command);
                FinalQuotation dataset = new FinalQuotation();
                adapter.Fill(dataset);
                ReportDocument Report = new ReportDocument();
                Report.Load(Server.MapPath("FinalQuotationReport.rpt"));
                ConnectionInfo connectionInfo = new ConnectionInfo();
                connectionInfo.DatabaseName = "crm_master"; //changed for security
                connectionInfo.UserID = "root"; //changed for security
                connectionInfo.Password = "root@123"; //changed for security
                connectionInfo.IntegratedSecurity = true;
                SetDBLogonForReport(connectionInfo, Report);
                Report.SetDataSource(dataset.Tables[1]);
                CrystalReportViewer1.ReportSource = Report;
        }
        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);
            }
        }
}
<pre>



the above code will execute finely when data set have only a single table ,but when you have multiple tables in data set the it is asking for user name and password  again and again no matter's about your right and wrong credentials it's keep asking you for that
Posted
Updated 22-Nov-15 18:39pm
v2
Comments
OriginalGriff 22-Nov-15 10:02am    
Share the code you are using - just the relevant bits.

Use the "Improve question" widget to edit your question and provide better information.
Suvendu Shekhar Giri 22-Nov-15 11:13am    
Share the relevant code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900