<add name="crm_masterConnectionString" connectionString="server=localhost;user id=root;password=root@123;persistsecurityinfo=true;database=crm_master" providerName="MySql.Data.MySqlClient" />
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
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)