asp.net mvc4 razor + Crystal Report + Oralcle

แนะนำ สอบถาม ภาษา C สำหรับผู้เริ่มต้น ภาษา Java ภาษา Python

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
jataz2
PHP Super Member
PHP Super Member
โพสต์: 275
ลงทะเบียนเมื่อ: 22/02/2011 11:48 am

asp.net mvc4 razor + Crystal Report + Oralcle

โพสต์ที่ยังไม่ได้อ่าน โดย jataz2 »

ถ้าท่านเจอปัญหาทั้่ง 4 ข้อ ใช้ code ด้านล่างได้เลยครับ :-)

1. Failed to open the connection.\nDetails: [Database Vendor Code: 12154 ]\rFailed to open the connection.\nDetails: [Database Vendor Code: 12154 ]\rFailed to open the connection.\nSubScription2 {052A197A-58FE-454F-AD33-09EA7676B95B}.rpt\nDetails: [Database Vendor Code: 12154

2. Logon failed.
Error in File SubScription2 {D8E9A692-C93D-47AD-B84B-52ADD7DCC3B8}.rpt:
Unable to connect: incorrect log on parameters.

3. Database logon failed.

4. Missing parameter

Solv all those above error by using this code
-----------------------------------------------------------------------

โค้ด: เลือกทั้งหมด

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

public ActionResult DetailsReport()
        {
            string paramSSID = "123456789";

            Sections crSections;
            ReportDocument crReportDocument, crSubreportDocument;
            SubreportObject crSubreportObject;
            ReportObjects crReportObjects;
            ConnectionInfo crConnectionInfo;
            Database crDatabase;
            Tables crTables;
            TableLogOnInfo crTableLogOnInfo;
            crReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            crReportDocument.Load(Server.MapPath("~/Reports/SubScription2.rpt"));


            crReportDocument.SetParameterValue("SSID", paramSSID);

            //set parameter for each subreport 
            crReportDocument.SetParameterValue("SSID", paramSSID, "CA");
            crReportDocument.SetParameterValue("SSID", paramSSID, "TD");
            crReportDocument.SetParameterValue("SSID", paramSSID, "ATM");
            crReportDocument.SetParameterValue("SSID", paramSSID, "Saving");
            crReportDocument.SetParameterValue("SSID", paramSSID, "IVR");
            crReportDocument.SetParameterValue("SSID", paramSSID, "IB");
            crReportDocument.SetParameterValue("SSID", paramSSID, "CIB");
            crReportDocument.SetParameterValue("SSID", paramSSID, "SMS");
            crReportDocument.SetParameterValue("SSID", paramSSID, "ATS");
            
            crDatabase = crReportDocument.Database;
            crTables = crDatabase.Tables;
            crConnectionInfo = new ConnectionInfo();
           
            crConnectionInfo.ServerName = "(DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=10.0.0.1)(PORT=5555))(CONNECT_DATA=(SERVICE_NAME=CUS)))";
            crConnectionInfo.UserID = "User01";
            crConnectionInfo.Password = "password";
            
            foreach (CrystalDecisions.CrystalReports.Engine.Table aTable in crTables)
            {
                crTableLogOnInfo = aTable.LogOnInfo;
                crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                aTable.ApplyLogOnInfo(crTableLogOnInfo);
            }

           
            crSections = crReportDocument.ReportDefinition.Sections;
 
            // loop through all the sections to find all the report objects 
            foreach (Section crSection in crSections)
            {
                crReportObjects = crSection.ReportObjects;
                //loop through all the report objects in there to find all subreports 
                

                foreach (ReportObject crReportObject in crReportObjects)
                {
                   
                    if (crReportObject.Kind == ReportObjectKind.SubreportObject)
                    {
                        crSubreportObject = (SubreportObject)crReportObject;
                        //open the subreport object and logon as for the general report 
                        crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
                        crDatabase = crSubreportDocument.Database;
                        crTables = crDatabase.Tables;

                        foreach (CrystalDecisions.CrystalReports.Engine.Table aTable in crTables)
                        {
                            crTableLogOnInfo = aTable.LogOnInfo;
                            crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                            aTable.ApplyLogOnInfo(crTableLogOnInfo);
                          
                        }
                    }
                }
            }


            crReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, true, "SubscribeReport");

            return View();
        }
ภาพประจำตัวสมาชิก
jataz2
PHP Super Member
PHP Super Member
โพสต์: 275
ลงทะเบียนเมื่อ: 22/02/2011 11:48 am

Re: asp.net mvc4 razor + Crystal Report + Oralcle

โพสต์ที่ยังไม่ได้อ่าน โดย jataz2 »

CrystalDecisions.CrystalReports.Engine .dll version is 12.0.1
Flyingdutshman
PHP Newbie
PHP Newbie
โพสต์: 2
ลงทะเบียนเมื่อ: 12/02/2015 1:50 pm

Re: asp.net mvc4 razor + Crystal Report + Oralcle

โพสต์ที่ยังไม่ได้อ่าน โดย Flyingdutshman »

เยี่ยมเลยครับ สำหรับความรู้ใหม่
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 94