Click here to Skip to main content
15,898,371 members
Home / Discussions / C#
   

C#

 
QuestionCompiler [modified] Pin
hiremath7120-Feb-07 22:59
hiremath7120-Feb-07 22:59 
QuestionCrystal Report Licence Pin
Banjo Ayorinde20-Feb-07 22:25
Banjo Ayorinde20-Feb-07 22:25 
QuestionAdding Items to combo box from a table field Pin
Banjo Ayorinde20-Feb-07 22:17
Banjo Ayorinde20-Feb-07 22:17 
AnswerRe: Adding Items to combo box from a table field Pin
Christian Graus20-Feb-07 23:09
protectorChristian Graus20-Feb-07 23:09 
AnswerRe: Adding Items to combo box from a table field Pin
Niiiissssshhhhhuuuuu20-Feb-07 23:12
Niiiissssshhhhhuuuuu20-Feb-07 23:12 
Questionhow can i send just one byte with serial port? Pin
Mir_As20-Feb-07 22:15
Mir_As20-Feb-07 22:15 
AnswerRe: how can i send just one byte with serial port? Pin
stancrm20-Feb-07 22:36
stancrm20-Feb-07 22:36 
QuestionLoading Report (Crystal Report) from my Application, after deployment. Pin
Banjo Ayorinde20-Feb-07 22:11
Banjo Ayorinde20-Feb-07 22:11 
Details
I used C#.Net 2005 and SQL 2000 as back end.
I wrote stored procedure to retrieve record (for the report) from the server.

I used Crystal Report (C#.Net 2005) to prepare the report through crystalReportViewer.
I also wrote codes in “Code View” of a Form to load the report.

The report runs perfectly in isolation.
The report also runs very well from the Application prior to deployment.

Problem
The report however, could not be loaded after deployment while other parts of the app run effectively.
It generates an error “Load Report Failed” when attempt to load the report is made.

Although, this is my first deployment with crystal report.


Assumption
I suspect the absence of required file(s) that should be added during deployment in order to aid the loading of a crystal report file, since the report runs in “IDE” before deployment or do you think otherwise?

There is also an insinuation from a friend of the need to add a product key or license key or registration number for the crystal report to work fine, which I do not know the procedure or know-how.
• Please assist in solving my problem so that I can deploy appropriately.

Thanks in advance.

Banjo Ayorinde






This is the code for the report:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;

namespace UI
{
public partial class rptFrmEmpEmpNo : Form
{
public rptFrmEmpEmpNo()
{
InitializeComponent();
}

private static rptFrmEmpEmpNo instance = null;

public static rptFrmEmpEmpNo getInstance()
{
if (instance == null)
instance = new rptFrmEmpEmpNo();
return instance;
}

// stirng to hold connection to the server
public string Link_DB_ConnectionString()
{
return "Server=.;initial catalog=LabourData;User ID=sa;Password=sa";
}

private long EmployeeNo;

// codes to fill Employee combo box with employee names
private void FillEmployeeCombo()
{
string EmpId,EmpNo,EmpLastName,EmpFirstName;

SqlConnection EmpNoConnect = new SqlConnection(Link_DB_ConnectionString());
try
{
EmpNoConnect.Open();
//Create SQL statement
string EmpNoString = "SELECT EmployeeId, EmployeeNo, LastName, FirstName FROM tbl_Employee ORDER BY LastName ASC";

SqlCommand EmpNoCommand = EmpNoConnect.CreateCommand();
EmpNoCommand.CommandText = EmpNoString;

// A SqlDataAdapter uses the SqlCommand object to fill a DataSet.
SqlDataAdapter EmpNoDataAdapter = new SqlDataAdapter(EmpNoCommand);

// Create a new Dataset and fill its first DataTable.
DataSet EmpNoDataset = new DataSet();
EmpNoDataAdapter.Fill(EmpNoDataset, "tbl_Employee");

// mySqlDataAdapter = new SqlDataAdapter(mySqlCommand);

SqlDataReader EmpNoDataReader = EmpNoCommand.ExecuteReader();

while (EmpNoDataReader.Read())
{
EmpId = EmpNoDataReader.GetValue(0).ToString();
EmpNo = EmpNoDataReader.GetValue(1).ToString();
EmpLastName = EmpNoDataReader.GetValue(2).ToString();
EmpFirstName = EmpNoDataReader.GetValue(3).ToString();

this.cmbEmployeeNo.Items.Add(EmpNo + " " + EmpLastName + " " + EmpFirstName);
this.LstEmpId.Items.Add(EmpNo);
}

EmpNoDataReader.Close();
EmpNoConnect.Close();

}
catch (Exception er)
{
MessageBox.Show(er.Message);
}
}

private void cmbEmployeeNo_SelectedIndexChanged(object sender, EventArgs e)
{
LstEmpId.SelectedIndex = cmbEmployeeNo.SelectedIndex;
EmployeeNo = Convert.ToInt64(LstEmpId.SelectedItem.ToString());
}

private void ClearEmployeeCombo()
{
cmbEmployeeNo.Items.Clear();
LstEmpId.Items.Clear();
}

private void rptFrmEmpEmpNo_Load(object sender, EventArgs e)
{
ClearEmployeeCombo();
FillEmployeeCombo();
}

private void bttnClose_Click(object sender, EventArgs e)
{
this.Close();
}


private string ServerName = ".";
private string UserID = "sa";
private string Password = "sa";
private string DatabaseName = "LabourData";


//codes to load the report through the report viewer
private void bttnDisplay_Click(object sender, EventArgs e)
{
// In this event the Customer Orders Report is loaded
// and displayed in the crystal reports viewer.
// This report calls for a parameter which is pulled
// from the customer name combo box (cbCustomers).
// Objects used to set the parameters in the report

CrystalDecisions.Shared.ParameterValues pvCollection = new CrystalDecisions.Shared.ParameterValues();

CrystalDecisions.Shared.ParameterDiscreteValue pdvEmpEmpNo = new CrystalDecisions.Shared.ParameterDiscreteValue();

// Objects used to set the proper database connection information


CrystalDecisions.Shared.TableLogOnInfo tliCurrent;

// Create a report document instance to hold the report

ReportDocument rptEmpEmpNo = new ReportDocument();

try
{

// Load the report

rptEmpEmpNo.Load(@"..\..\YCrystalReportEmpEmpNo.rpt");

// Set the connection information for all the tables used in the report
// Leave UserID and Password blank for trusted connection

foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rptEmpEmpNo.Database.Tables)
{

tliCurrent = tbCurrent.LogOnInfo;

tliCurrent.ConnectionInfo.ServerName = ServerName;
tliCurrent.ConnectionInfo.UserID = UserID;
tliCurrent.ConnectionInfo.Password = Password;
tliCurrent.ConnectionInfo.DatabaseName = DatabaseName;
tbCurrent.ApplyLogOnInfo(tliCurrent);

}

// Set the discreet value to the reg number.

pdvEmpEmpNo.Value = LstEmpId.Text;

// Add it to the parameter collection.

pvCollection.Add(pdvEmpEmpNo);

// Apply the current parameter values.

rptEmpEmpNo.DataDefinition.ParameterFields["@EmployeeNo"].ApplyCurrentValues(pvCollection);

// Hide group tree for this report

crvEmpEmpNo.DisplayGroupTree = false;

// Set the report source for the crystal reports viewer to the
// report instance.

crvEmpEmpNo.ReportSource = rptEmpEmpNo;

// Zoom viewer to fit to the whole page so the user can see the report

crvEmpEmpNo.Zoom(1);

}

catch(LoadSaveReportException Exp)
{
MessageBox.Show("Incorrect path for loading report.", "Load Report Error");
}

catch( Exception Exp)
{
MessageBox.Show(Exp.Message, "General Error");
}
}


}
}



Banjo Ayorinde
QuestionProblem in loading form Urgent please Pin
NK720-Feb-07 20:47
NK720-Feb-07 20:47 
AnswerRe: Problem in loading form Urgent please Pin
NK720-Feb-07 20:48
NK720-Feb-07 20:48 
AnswerRe: Problem in loading form Urgent please Pin
PandemoniumPasha20-Feb-07 22:11
PandemoniumPasha20-Feb-07 22:11 
GeneralRe: Problem in loading form Urgent please Pin
NK720-Feb-07 22:25
NK720-Feb-07 22:25 
GeneralRe: Problem in loading form Urgent please Pin
NK720-Feb-07 22:41
NK720-Feb-07 22:41 
QuestionHow to retrieve list of users from particular Active Directory Group Pin
prabhakaranns20-Feb-07 20:40
prabhakaranns20-Feb-07 20:40 
Questionproblem in web form loading Pin
EEmaan20-Feb-07 20:32
EEmaan20-Feb-07 20:32 
AnswerRe: problem in web form loading Pin
il_masacratore20-Feb-07 21:34
il_masacratore20-Feb-07 21:34 
AnswerRe: problem in web form loading Pin
K.P.Kannan20-Feb-07 22:11
K.P.Kannan20-Feb-07 22:11 
QuestionWindows File System Refresh in C# Application Pin
Sunil Jampa20-Feb-07 19:23
Sunil Jampa20-Feb-07 19:23 
AnswerRe: Windows File System Refresh in C# Application Pin
Niiiissssshhhhhuuuuu20-Feb-07 19:52
Niiiissssshhhhhuuuuu20-Feb-07 19:52 
GeneralRe: Windows File System Refresh in C# Application Pin
Niiiissssshhhhhuuuuu20-Feb-07 19:55
Niiiissssshhhhhuuuuu20-Feb-07 19:55 
GeneralRe: Windows File System Refresh in C# Application Pin
Sunil Jampa20-Feb-07 20:17
Sunil Jampa20-Feb-07 20:17 
GeneralRe: Windows File System Refresh in C# Application Pin
Niiiissssshhhhhuuuuu20-Feb-07 20:31
Niiiissssshhhhhuuuuu20-Feb-07 20:31 
QuestionPop Up Menu Pin
hiremath7120-Feb-07 19:21
hiremath7120-Feb-07 19:21 
AnswerRe: Pop Up Menu Pin
Niiiissssshhhhhuuuuu20-Feb-07 20:12
Niiiissssshhhhhuuuuu20-Feb-07 20:12 
GeneralRe: Pop Up Menu Pin
hiremath7120-Feb-07 21:52
hiremath7120-Feb-07 21:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.