Error 2 'System.Web.HttpApplicationState' does not contain a definition for 'startuppath' and no extension method 'startuppath' accepting a first argument of type 'System.Web.HttpApplicationState' could be found (are you missing a using directive or an assembly reference?) E:\Report1\global\Default.aspx.cs 77 36 E:\Report1\global\


please help me..
i want to override the connection string of crystal reports which was connected by the database experts..
now i want to override with with new connection string .. the above error is diaplaying..
the following is my code if there is any mistake please correct me...
its urgent please help me....

the code is..

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data.OleDb;
using CrystalDecisions.Enterprise;


public partial class _Default : System.Web.UI.Page
{
    string connections = ConfigurationManager.ConnectionStrings["SqlConn"].ConnectionString;
    private TableLogOnInfo LogInfo = new TableLogOnInfo();
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

         

          }


    }



    private void SetLogonInfo()
    {
        try
        {
            LogInfo.ConnectionInfo.ServerName = "";
            LogInfo.ConnectionInfo.UserID = "";
            LogInfo.ConnectionInfo.Password = "";
            LogInfo.ConnectionInfo.DatabaseName = "";
        }
        catch (Exception e)
        {
            
        }
    }
    //private void setDBLOGONforREPORT(ConnectionInfo myconnectioninfo)
    //{
    //    TableLogOnInfos mytableloginfos = new TableLogOnInfos();
    //    mytableloginfos = CrystalReportViewer1.LogOnInfo;
    //    foreach (TableLogOnInfo myTableLogOnInfo in mytableloginfos)
    //    {
    //        myTableLogOnInfo.ConnectionInfo = myconnectioninfo;
    //    }

    //}

      protected void btn_emp_Click(object sender, EventArgs e)
    {
        // string connections = ConfigurationManager.ConnectionStrings["SqlConn"].ConnectionString;
        // string connections = "Data Source=VSSPL-002\\SQLEXPRESS;Initial Catalog=employee;Integrated Security=True";
        string myQuery = "select * from employee";
        SqlConnection myConnection = new SqlConnection(connections);
        SqlCommand myCommand = new SqlCommand(myQuery, myConnection);
        myCommand.Connection.Open();
        SqlDataAdapter da = new SqlDataAdapter(myCommand);
        DataSet dt = new DataSet();
        da.Fill(dt);
        DataTable td = dt.Tables[0];
 
         ReportDocument myreport = new ReportDocument();
         string path = Application.startuppath + "~/" + "emp.rpt";
         myreport.Load(path);
         myreport.Database.Tables[0].ApplyLogOnInfo(LogInfo);
         myreport.SetDataSource(td);
         CrystalReportViewer1.ReportSource = myreport;
          // myreport.Load(MapPath("~/" + "emp.rpt"));
         //myreport.Database.Tables[0].SetDataSource(td);
         //CrystalReportViewer1.ReportSource = myreport;
         //int count = Convert.ToInt32(dt.Tables[0].Rows.Count);
         myConnection.Close();
          
      }

Application.Startuppath is use to windows application. You use to Server.mappath("")

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.