Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My code:
C#
SqlDBAccess db = new SqlDBAccess();
        ReportDocument report;
        private void btnSave_Click(object sender, EventArgs e)
        {
            Wait wait = new Wait();
            report = new ReportDocument();
            string reportPath = Application.StartupPath + "\\Reports\\" + "TabulationSheet1to5.rpt";
            report.Load(reportPath);
            try
            {
                if (comClass.Text.ToString() == "<< Select Class >>".ToString() || comExam.Text.ToString() == "<<Select Turm>>")
                {
                    MessageBox.Show("Please select class and exam...", "Required Field", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
                else
                {
                    wait.Show();
                    Cursor.Current = Cursors.WaitCursor;
                    db.Adapter("drop table tabulationSheet1");
                    db.Adapter("select * into tabulationSheet1 from tabulationSheet1To5 where Class = '"
                        + comClass.Text.ToString() + "' and Exam = '" + comExam.Text.ToString() + "' and YearAt = '"+dateTimeYear.Text.ToString()+"'");
                    report.SetDataSource(db.Adapter("select SchoolName, Logo, Add1, Add2,"
                        + " StudentName,RollNo,Bangla1Sub,Bangla1Obj, "
                        + " Bangla2Sub, Bangla2Obj, English1Sub, English1Obj,English2Sub,"
                        + " Math,IslamicStudiesSub,IslamicStudiesObj,HinduReligiousStudiesSub,"
                        + " HinduReligiousStudiesObj,BuddhistReligiousStudiesSub,BuddhistReligiousStudiesObj,"
                        + " ParibeshParichitiBigganSub,ParibeshParichitiBigganObj,ParibeshPaichitiShomajSub,"
                        + " ParibeshPaichitiShomajObj,GeneralKnowledge,PhysicalEducationAndHealth,"
                        + " Srutilipi,Drawing,Class,Exam,MonthAt,YearAt,Dated"
                        + " from Activation, tabulationSheet1"));
                    crystalReportViewer1.ReportSource = report;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                wait.Dispose();
                Cursor.Current = Cursors.Default;
            }
            finally
            {
                wait.Dispose();
                Cursor.Current = Cursors.Default;
            }
        }

My App.Config is:
XML
<?xml version="1.0" encoding="utf-8" ?>

<configuration>
  <configSections>
  </configSections>
  <appSettings>
    <!--   User application and configured property settings go here.-->
    <!--   Example: <add key="settingName" value="settingValue"/> -->
    <add key="SqlConnectionString" value="Data Source=PLATFORM-FED393\SQLEXPRESS;Initial Catalog=PlatFormDB1;user=abeer;password=database;Integrated Security=True"/>

  </appSettings>
  
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="PickupDirectoryFromIis">
        <network defaultCredentials="true" host="localhost" port="587"/>
      </smtp>
    </mailSettings>
  </system.net>
</configuration>

My Problem:
When I am executing my code Crystalreportviewer asking for user name and password. When Im puting user name and password Login Failed for server name. I want to avoid this server name, user name and password for show report. Can anybody help me how can I connect App.configFile in my Crystalreportviewer for showing report.
Posted
Updated 5-Jul-12 23:32pm
v2

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