Skip to main content

crystal reports using stored procedures in asp.net



 

crystal reports using stored procedures in asp.net

 




ReportDocument document = new ReportDocument();
        document.Load(this.Page.Server.MapPath("~/CRY/crTest.rpt"));
        string str = ConfigurationManager.AppSettings["ConnectionString"];
        string server = str.Substring(str.IndexOf("=") + 1, str.IndexOf(";") - (str.IndexOf("=") + 1));
        str = str.Substring(str.IndexOf(";") + 1);
        string database = str.Substring(str.IndexOf("=") + 1, str.IndexOf(";") - (str.IndexOf("=") + 1));
        str = str.Substring(str.IndexOf(";") + 1);
        string user = str.Substring(str.IndexOf("=") + 1, str.IndexOf(";") - (str.IndexOf("=") + 1));
        str = str.Substring(str.IndexOf(";") + 1);
        string password = str.Substring(str.IndexOf("=") + 1);
        document.DataSourceConnections.Clear();
        document.DataSourceConnections[0].SetConnection(server, database, user, password);
        new TableLogOnInfos();
        TableLogOnInfo logonInfo = new TableLogOnInfo();
        ConnectionInfo info2 = new ConnectionInfo();
        info2.ServerName = server;
        info2.DatabaseName = database;
        info2.UserID = user;
        info2.Password = password;
        foreach (CrystalDecisions.CrystalReports.Engine.Table table in document.Database.Tables)
        {
            logonInfo = table.LogOnInfo;
            logonInfo.ConnectionInfo = info2;
            table.ApplyLogOnInfo(logonInfo);
        }
        document.SetDatabaseLogon(user, password, server, database);
        document.Refresh();
        for (int i = 0; i < document.ParameterFields.Count; i++)
        {
            document.SetParameterValue(document.ParameterFields[i].Name, 1);
        }
        this.CrystalReportViewer1.ReportSource = document;

Comments

Popular posts from this blog

Tata Punch: A Compact SUV That Packs a Punch

Message Helper for MVC Application

Message Helper for MVC Application public static class MessageExtensions { public enum MessageType { Success = 0, Info = 1, Warning = 2, Error = 3 } public static void ShowMessage( this Controller controller, MessageType messageType, string message, bool showAfterRedirect = false ) { string messageTypeKey = messageType.ToString(); if (showAfterRedirect) { controller.TempData[messageTypeKey] = message; } else { controller.ViewData[messageTypeKey] = message; } } public static HtmlString RenderMessages( this HtmlHelper htmlHelper, bool clearMessage = true ) { string messages = String .Empty; foreach ( string messageType in Enum .GetNames( t...

Postback Page using Javascript in ASP.net

Postback Page using Javascript in ASP.net For Calling Function: __doPostBack('__Page', ''); Function: function __doPostBack(eventTarget, eventArgument) {         if (!theForm.onsubmit || (theForm.onsubmit() != false)) {             theForm.__EVENTTARGET.value = eventTarget;             theForm.__EVENTARGUMENT.value = eventArgument;             theForm.submit();         }     }