Posted by: R Manimaran | September 8, 2008

Crystal Report Server -CMS Server Error

 

When you start the CMS serer you may get this error.( Check in the event log)

Error

Unexpected value for parameter DatabaseConnectString

The root server reported an error Initialization Failure.

 

Resolution

The CMS database is not configured correctly. Configure the CMS database using the Central Configuration Manager.

 

 

Error 2:

Failed to write the database connection string to registry

 

CMS uses the libeay.dll to run. This dll is available in the Windows/System32 folder. If this dll is  not available or any other new application overwrites the existing one, this error will occur.

Check this dll. I also come across this error. I have the backup of this dll. After I put the dll in the system32 folder, CMS started successfully.

Posted by: R Manimaran | August 28, 2008

Crystal Report Server operations using .net SDK

Crystal Report Server operations using .net SDK

 

  • Get Folder ID from Crystal Report Server using .net sdk

 

public static int GetFolderID(InfoStore infoStore, string folderName)

{

string Query = “Select SI_ID FROM CI_INFOOBJECTS WHERE

SI_KIND=’Folder’ and SI_Name=’” + folderName + “‘”;

InfoObjects infoObjects = infoStore.Query(Query);

      if (infoObjects.Count > 0)

      {

            InfoObject infoObject = infoObjects[1];

            int folderId = infoObject.ID;

            return folderId;

       }

       else

       {

       return -1;

       //throw new Exception(“NO MATCHES FOUND”);

       }

 }

 

  • Get Folder ID from Crystal Report Server  under a Parent  folder

 

public static int GetFolderID(InfoStore infoStore, string folderName, int ParentFolderID)

 {

 string Query = “Select SI_ID FROM CI_INFOOBJECTS WHERE

     SI_KIND=’Folder’ and SI_Name=’” +

                 folderName + “‘ AND SI_PARENTID=” + ParentFolderID;

 

      InfoObjects infoObjects = infoStore.Query(Query);

      if (infoObjects.Count > 0)

      {

            InfoObject infoObject = infoObjects[1];

      int folderId = infoObject.ID;

            return folderId;

      }

      else

      {

      return -1;

                //throw new Exception(“NO MATCHES FOUND”);

      }

  }

 

  • Add a Repoort to the CMS –Crystal Report Server using .net sdk

 

public static void AddReport(InfoStore infostore, string reportName)

{

InfoObjects infoObjects = infostore.NewInfoObjectCollection();

      PluginManager pluginManager = infostore.PluginManager;

      PluginInfo pluginInfo =

pluginManager.GetPluginInfo(“CrystalEnterprise.Report”);

      InfoObject infoObject = infoObjects.Add(pluginInfo);

      Report report = new Report(infoObject.PluginInterface);

report.Files.Add(reportName);//error

      report.Properties.Add(“SI_PARENTID”, folderId);

      report.EnableThumbnail = true;

      report.NeedsLogon = true;

      report.KeepSavedData = true;

//Store the file name as Description

      FileInfo fileinfo = new FileInfo(filename);

      report.Description = fileinfo.Name;

      for (int i = 1; i <= report.ReportLogons.Count; i++)

      {

            report.ReportLogons[i].CustomUserName = “<username>”;

      report.ReportLogons[i].CustomPassword = “<passport>”;

            report.ReportLogons[i].CustomDatabaseName = “<database>”;

      report.ReportLogons[i].UserName = “<username-value>”;

      report.ReportLogons[i].Password = “<password-value>”;

            report.ReportLogons[i].PromptOnDemandViewing = false;

      }

infostore.Commit(infoObjects);

}

 

 

  • Add a Folder to the Crystal Report Server using .net sdk

 

public static int AddFolder(InfoStore infoStore, int parentFolderID,

string FolderName, string FolderDescription)

{

int folderID = -1;

      try

      {

      InfoObjects infoObjects = infoStore.NewInfoObjectCollection();

      PluginManager pluginManager = infoStore.PluginManager;

      PluginInfo pluginInfo =

pluginManager.GetPluginInfo(“CrystalEnterprise.Folder”);

      InfoObject infoObject = infoObjects.Add(pluginInfo);

      Folder folder = new Folder(infoObject.PluginInterface);

      folder.Title = FolderName;

      folder.Description = FolderDescription;

      folder.Properties.Add(“SI_PARENTID”, parentFolderID);

      folderID = folder.ID;

      infoStore.Commit(infoObjects);

      return folderID;

      }

      catch (Exception ex)

      {

            if (ex.Message.ToString().Contains(“Duplicate”))

      {

      folderID = GetFolderID(infoStore, FolderName,

parentFolderID);

      return folderID;

      }

            else

Log.WriteFile(“Error adding folder to Crystal Report

Server. Message:” +

ex.Message,Log.LogFileType.ERROR);

      }

}

            return folderID;

        }

 

  • Delete Folder in the Crystal Report Server using .net SDK

 

private static void DeleteFolder(InfoStore infoStore, int

parentFolderID, string FolderName)

{

try

      {

      string Query = “Select SI_ID FROM CI_INFOOBJECTS WHERE

    SI_KIND=’Folder’ and SI_Name=’” +

                      FolderName + “‘ AND SI_PARENTID=” +

    parentFolderID;

       InfoObjects infoObjects = infoStore.Query(Query);

       if (infoObjects.Count > 0)

       {

            InfoObject infoObject = infoObjects[1];

            int folderId = infoObject.ID;

            infoObject.DeleteNow();

            Log.WriteFile(“Deleting the Folder :” + FolderName + ” in

Crystal Report Server”, Log.LogFileType.INFO);

        }

        else

        {

            // return -1;

            //throw new Exception(“NO MATCHES FOUND”);

            Log.WriteFile(“No folder of name “ + FolderName + ” found

in Crystal Report Server”, Log.LogFileType.INFO);

         }

       }

       catch (Exception ex)

       {

       throw new ApplicationException(“Error Deleting Product Folder:”

+ FolderName +                                                ” from Crystal Report Server. Message:”+ex.Message);

        }

 }

 

  • Move a Object from one folder to another folder in Crystal Report Server using .net SDK

 

private static void MoveObjects(InfoStore infoStore, int

ObjectFolderID, int parentFolderID, int newFolderID)

 {

      try

      {

            string Query = “Select SI_ID FROM CI_INFOOBJECTS WHERE

    SI_KIND=’Folder’ and SI_ID=” +

    ObjectFolderID + ” AND SI_PARENTID=” +

     parentFolderID;

InfoObjects infoObjects = infoStore.Query(Query);

            if (infoObjects.Count > 0)

            {

                  InfoObject infoObject = infoObjects[1];

 

                    int folderId = infoObject.ID;

                    //infoObject.DeleteNow();

                    Folder folder = new

   Folder(infoObject.PluginInterface);

                    folder.Properties.Add(“SI_PARENTID”, newFolderID);

                    int folderID = folder.ID;

                    infoStore.Commit(infoObjects);

                    //int cnt = infoObject.Files.Count;

                    //return folderId;

                }

                else

                {

                    // return -1;

                    //throw new Exception(“NO MATCHES FOUND”);

                }

            }

            catch (Exception ex)

            {

                throw new ApplicationException(“Error moving Folder in

    Crystal Report Server. Message:”+ex.Message);

            }

 

        }

Posted by: R Manimaran | August 28, 2008

Connecting to Crystal Report Server using .net SDK

using CrystalDecisions.Enterprise; 

using CrystalDecisions.Enterprise.Desktop;

using CrystalDecisions.Enterprise.Viewing;
using CrystalDecisions.ReportAppServer.Controllers;
private

static InfoStore infoStore;

 

static void ConnectCrystalServer()
{
try
{
Log.WriteFile(“Connecting to CMS…”, Log.LogFileType.INFO);
SessionMgr sessionMgr = new SessionMgr();
EnterpriseSession enterpriseSession = sessionMgr.Logon(Common.sCR_UserName,Common.sCR_Password,Common.sCR_CMSName,
Common.sCR_Authentication);
EnterpriseService enterpriseService = enterpriseSession.GetService(“InfoStore”);
Log.WriteFile(“Connected Successfully to CMS”,Log.LogFileType.INFO);
Log.WriteFile(Log.Decorate(“\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t”, ‘-’, Log.DEC_STYLE.DEC_BOTTOM), Log.LogFileType.INFO); 
Log.WriteFile(string.Empty, Log.LogFileType.INFO);
infoStore =new InfoStore(enterpriseService);
}
catch (Exception  ex)
{
//Unable to connect to Crystal Report Server
Log.WriteFile(“Unable to connect to Crystal Report Server. Message:” + ex.Message,
Log.LogFileType.ERROR);
}
}

 

 

 

 

 

 

I am using Crystal Report Server XI and  Crystal Report XI R1. Using the .net SDK i try to publish my report in the CMC Server. If the reports does not contain any Parameters, then the reports are published correctly. But if the reports contains any parameters the following error is occured.

Failed to read data from report file <filename> Reason: Failed to read parameter object

Solution:

I download and install the Service pack for the Crystal Report XI R1. This fixes my error and it’s working fine. You can download the Crystal Report Service pack from the following link.

http://resources.businessobjects.com/support/additional_downloads/service_packs/crystal_reports_en.asp#CRXIR2

Posted by: R Manimaran | August 28, 2008

Crystal Report Infoview error: Unable to retrieve object.

Error in Infoview:

 

            Unable to retrieve object.

            Could not create an Object of type ‘CrystalReports.CrystalImageCleaner’

 

            Or

            Unable to retrieve object

            Object reference not set to instance of the object

 

 

 

Solution:

            This error is due to conflict in the Business objects dll or the following dlls may be unregistered.

 

            Register the following dll using the Regsvr32 command.

 

regsvr32    “C:\Program Files\Business Objects\common\3.5\bin\WebReporting.dll”

regsvr32    ”C:\Program Files\Business Objects\common\3.5\bin\ReportSourceBridge.dll”

regsvr32    ”C:\Program Files\Business Objects\common\3.5\bin\CEReportSource.dll”

regsvr32     “C:\Program Files\Business Objects\BusinessObjects Enterprise 11.5\win32_x86\EnterpriseFramework.dll”

Posted by: R Manimaran | August 18, 2008

Cricinfo International Scores

Live Cricket
Posted by: R Manimaran | August 5, 2008

Get a copy of dll in GAC (or) add Reference to a dll in GAC

Sometimes in .net application we need to have a copy of a dll which is available in GAC. But when we view the GAC through C:\Windows\assembly folder or Runà assembly it will show like this

Using this we cannot copy the dll. Only uninstall option is available.

To view the available dll using the naked eye follow the steps

Dot net have a dll file Shfusion.dll which is a Assembly Cache Viewer. It is located in the following path.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll

  1. uninstall the dll using the following command in the run dialog box.

regsvr32 -u C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll

  1. Now type assembly in the Run dialog box.
  2. Now you will see the folder view of the GAC. copy the dll you want.

Note:

To get back to the previous state of view register the Shfusion dll using the following command

regsvr32 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll

When you are using an object that encapsulate any resource, then you have to ensure whether Objects Dispose method is called to clean up the resources.

The same thing can be better done by using the “using” statement in C#.

 

This using statement

  • Simplifies the code
  • Finally clean up the object after the code completion

 

Thus the using statement

·         obtains the resources specified

·         executes the statements

·         finally calls the Dispose method to cleanup the object

 

For ex:

 

using (XmlDocument doc = new XmlDocument())

{

     doc.Load(filename);

     //other operation regarding the xml document

}

Ex.2

using (Myclassmyobj = new Myclass())

 {

   myobj.MyMethod();

 }

Which is similar to

 

Myclassmyobj = new Myclass();

  try

  {

     myobj.MyMethod();

  }

  finally

  {

      if(myobj != null)

      ((IDisposable)myobj).Dispose();

  }

The good usauge of using is in the Database opertaions.

 

DataSetds = new DataSet();
using (SqlConnectionconn = new SqlConnection(this._connectionString))
{
   stringsqlComm = “SET DATEFORMAT DMY “;
   sqlComm += “SELECT * FROM Sample”;
   conn.Open();
   using (SqlCommand comm = new SqlCommand(sqlComm, conn))
   {
      comm.CommandType = CommandType.Text;
      SqlDataAdapterda = new SqlDataAdapter(comm);
      da.Fill(ds, tableName);
  
}
}

or use try/catch/finally

SqlConnectionconn = null;
SqlCommand comm = null;
SqlDataAdapterda = null;
try
{
   conn = new SqlConnection(connectionString);
   sqlComm += “SELECT * FROM Sample”;
   comm = new SqlCommand(sqlComm, conn);
   comm.CommandType = CommandType.Text;
   da = new SqlDataAdapter(comm);
   DataSetds = new DataSet();
   da.Fill(ds, tableName);
}
catch (Exception ex)
{
   // manage exception
}
finally
{
   if(conn != null)
      conn.Dispose();
   if (comm != null)
      comm.Dispose();
   if(da != null)
     
da.Dispose();
}

 

Note:

The using statement is only useful for objects with a lifetime within a method.

The objects you instantiate must implement the System.IDisposable interface

Using the params keyword we can pass the variable number of arguments to a method at runtime. There is some restriction using the params keyword

 

  • You can only use the params keyword for one parameter in your method declaration.
  • params must always be the last parameter

 

Example

 

public void ObjectParamsMethod(string strMessage, params object[] p)

    {

      Console.Write(strMessage);

      for (int i = 0; i < p.Length; i++)

        {

           Console.WriteLine(p[i].ToString());

         }

  }

 

//Calling ObjectParamsMethod

ObjectParamsMethod(“Variable Object parameters using param”, “name”, ‘c’, 2008, 12.4);

 

If we know the type of arguments we are going to passing then we can optimize our params as follows. Suppose our argument is going to be variable number of string then we can pass this as

 

public void ObjectParamsMethod(string strMessage, params string[] p)

 

    {

      Console.Write(strMessage);

      for (int i = 0; i < p.Length; i++)

        {

           Console.WriteLine(p[i].ToString());

         }

  }

 //Calling ObjectParamsMethod

ObjectParamsMethod(“Variable string parameters using param”, “name”, “Age”,  

                   ”Location”, “ZipCode”, “Contact”);

 

 

 

If it is of int type then

 public void ObjectParamsMethod(string strMessage, params int[] p)

    {

      Console.Write(strMessage);

      for (int i = 0; i < p.Length; i++)

        {

           Console.WriteLine(p[i].ToString());

         }

  }

//Calling ObjectParamsMethod

ObjectParamsMethod(“Variable int parameters using param”,10,12,35,56);

 

 Instead of using comma as a Separated we can pass an array as the parameter.

 string[] MyParamArray ={ “name”, “Age”, “Location”, “ZipCode”“Contact” };

ObjectParamsMethod(“Variable Object parameters using param”,  MyParamArray);

 

 

 

Posted by: R Manimaran | July 9, 2008

BackgroundWorker in C# Threading

BackgroundWorker is a helper class in the System.ComponentModel namespace for managing a worker thread. It provides the following features:

  • A “cancel” flag for signaling a worker to end without using Abort
  • A standard protocol for reporting progress, completion and cancellation
  • An implementation of IComponent allowing it be sited in the Visual Studio Designer
  • Exception handling on the worker thread
  • The ability to update Windows Forms and WPF controls in response to worker progress or completion.

Example

using System;
using System.Threading;
using System.ComponentModel;
 
class Program {
  static BackgroundWorker bw;
  static void Main() {
    bw = new BackgroundWorker();
    bw.WorkerReportsProgress = true;
    bw.WorkerSupportsCancellation = true;
    bw.DoWork += bw_DoWork;
    bw.ProgressChanged += bw_ProgressChanged;
    bw.RunWorkerCompleted += bw_RunWorkerCompleted;
 
    bw.RunWorkerAsync ("Hello to worker");
   
    Console.WriteLine ("Press Enter in the next 5 seconds to cancel");
    Console.ReadLine();
    if (bw.IsBusy) bw.CancelAsync();
    Console.ReadLine();
  }
 
  static void bw_DoWork (object sender, DoWorkEventArgs e) {
    for (int i = 0; i <= 100; i += 20) {
      if (bw.CancellationPending) {
        e.Cancel = true;
        return;
      }
      bw.ReportProgress (i);
      Thread.Sleep (1000);
    }
    e.Result = 123;    // This gets passed to RunWorkerCompleted
  } 
  static void bw_RunWorkerCompleted (object sender,
  RunWorkerCompletedEventArgs e) {
    if (e.Cancelled)
      Console.WriteLine ("You cancelled!");
    else if (e.Error != null)
      Console.WriteLine ("Worker exception: " + e.Error.ToString());
    else
      Console.WriteLine ("Complete - " + e.Result);      // from DoWork
  }
   static void bw_ProgressChanged (object sender,
  ProgressChangedEventArgs e) {
    Console.WriteLine ("Reached " + e.ProgressPercentage + "%");
  }
}
Output

Background worker

Background worker

« Newer Posts - Older Posts »

Categories