|
byte[] b = new byte[1] { 10 };
serialport1.Write(b, 0, b.Length);
|
|
|
|
|
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
|
|
|
|
|
Hi
I have problem in loading form back and forth. In form1 if i click next button I am showing form2 and hiding the form one. But when i click the cancel button in the form2 it will ask do you wan to exit with ok and cancel button if i click ok it is exiting the current application. if i click cancel the application is still running but i could able to see any form. any one help me please.
form1 code:
```````````
btnnext_click(object sender,eventargs e)
{
form2 objform2=new form2(this);
objform2.ShowDialog();
}
btncancel_click(object sender,eventargs e)
{
if(messagebox.show("Do you want to exit","Exiting", messageboxokcancel,messageboxquestion).equals(dialogresult.ok)
system.window.form.exit();
}
form2 code:
```````````
private Form frmForm1;
public form2(Form objForm)
{
frmForm1=objForm;
}
btnnext_click(object sender,eventargs e)
{
form3 objform3=new form3(this);
objform2.ShowDialog();
}
btncancel_click(object sender,eventargs e)
{
if(messagebox.show("Do you want to exit","Exiting", messageboxokcancel,messageboxquestion).equals(dialogresult.ok)
system.window.form.exit();
}
btnback_click(object sender, eventargs e)
{
frmForm1.visible=true;
}
kesavan
|
|
|
|
|
Hi
I have problem in loading form back and forth. In form1 if i click next button I am showing form2 and hiding the form one. But when i click the cancel button in the form2 it will ask do you wan to exit with ok and cancel button if i click ok it is exiting the current application. if i click cancel the application is still running but i could able to see any form. any one help me please.
form1 code:
```````````
btnnext_click(object sender,eventargs e)
{
form2 objform2=new form2(this);
objform2.ShowDialog();
}
btncancel_click(object sender,eventargs e)
{
if(messagebox.show("Do you want to exit","Exiting", messageboxokcancel,messageboxquestion).equals(dialogresult.ok)
system.window.form.exit();
}
form2 code:
```````````
private Form frmForm1;
public form2(Form objForm)
{
frmForm1=objForm;
}
btnnext_click(object sender,eventargs e)
{
form3 objform3=new form3(this);
objform2.ShowDialog();
}
btncancel_click(object sender,eventargs e)
{
if(messagebox.show("Do you want to exit","Exiting", messageboxokcancel,messageboxquestion).equals(dialogresult.ok)
system.window.form.exit();
}
btnback_click(object sender, eventargs e)
{
frmForm1.visible=true;
}
form2_load()
{
------ some code
------ some code
frmForm1.visible=false;
}
sorry i missed the load event. Any one help me please
kesavan
|
|
|
|
|
i'm not quite sure what exactly is you problem, is it not being to close the application or not being able to show the forms.
but i did have a look at your code. the code below is in c# (which is similar to your code) and worked fine for me.
form1:
------
<br />
private void btncancel_Click(object sender, System.EventArgs e)<br />
{<br />
if(MessageBox.Show("Do you want to exit","Exiting",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)<br />
Application.Exit();<br />
}<br />
<br />
private void btnnext_Click(object sender, System.EventArgs e)<br />
{<br />
Form2 objform2=new Form2(this);<br />
objform2.ShowDialog();<br />
}
form2:
------
<br />
private Form1 frmForm1;<br />
public Form2(Form1 objForm)<br />
{<br />
frmForm1=objForm;<br />
}<br />
private void btncancel_Click(object sender, System.EventArgs e)<br />
{<br />
if(MessageBox.Show("Do you want to exit","Exiting", MessageBoxButtons.OKCancel,MessageBoxIcon.Question) ==DialogResult.OK)<br />
Application.Exit();<br />
}<br />
<br />
private void butback_Click(object sender, System.EventArgs e)<br />
{<br />
frmForm1.Visible=true;<br />
this.Close();<br />
}<br />
<br />
private void Form2_Load(object sender, System.EventArgs e)<br />
{<br />
frmForm1.Visible=false;<br />
}<br />
|
|
|
|
|
Hi
What is my problem is if i click btcancel_clcik it will ask do you want to exit right?. In that message box(ok button and cancel button) if i click cancel i cant able to see any form.
kesavan
|
|
|
|
|
Hi
I solved the problem by changing showdialog to show.
i mean form1.showdialog() to form1.show()
Anyway thanks for spending your time for me
kesavan
|
|
|
|
|
Hi Friends
I would like to retrieve all the users from a particular Active Directory group. Can anyone tell me how to do this. I tried but i got this error:
There is no such object on the server
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: There is no such object on the server
This is my coding:
DirectoryEntry deGroup = new DirectoryEntry ("LDAP://cn=groupName,dc=itech,dc=com");
foreach(object oMember in deGroup.Properties["member"])
{
Response.Write(oMember.ToString());
}
|
|
|
|
|
hi!
whenever an click event of any control occurs in my C# asp.net web application(visual studio.net 2003), form load is called again and all controls are initialized. Like i m using check box in my grid and want to capture my check state against any button click. But when i click button then form is again loaded and all check boxex became converted in their default state(which is unchecked).
therefore the following condition in my button click event alwayx bacame false coz at that time no check box is in checked state.
the condition is
if(checkbox.checked)
i have many other problems also due to this from loading against any event. Therefore can u tell me how to stop this loading every time.
|
|
|
|
|
Hi,
Are you controlling if the PageLoad is from a postback (IsPostBack porperty)?
|
|
|
|
|
Check whether viewstate is disabled at any level.
Control/Page/Web.Config
|
|
|
|
|
Hi,
I have a C# appln, which contains a explorer style Tree view. Whenever any folder or file is created in the Windows Explorer externally, my application Tree view has to update. Is there any windows file system refresh event or message is there to call my method to update Treeview.
I hope you understand what I mean.
Thanks in advance...
Best Regards,
Sunil Jampa.
|
|
|
|
|
|
Hello,
// Create a new FileSystemWatcher and set its properties.
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = args[1];
/* Watch for changes in LastAccess and LastWrite times, and
the renaming of files or directories. */
watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.FileName | NotifyFilters.DirectoryName;
// Only watch text files.
watcher.Filter = "*.txt";
// Add event handlers.
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.Deleted += new FileSystemEventHandler(OnChanged);
watcher.Renamed += new RenamedEventHandler(OnRenamed);
// Begin watching.
watcher.EnableRaisingEvents = true
Regards ,
nishu
|
|
|
|
|
Hi Nishu,
Thanks for the reply!
Actually, whenever any file or folder is created/deleted in any drive irrespective of path in the Windows explorer, my method has to update for that event.
Here Path you mentioned is particular to a specified directory, if i am right. But external changes to the Windows explorer, I dont know which file/folder in which directory, it was changed.
How can I update my Tree view, if any Windows Explorer File System refreshes. I need a standard File System Refresh done by windows explorer.
Thanks again in advance...
Best Regards,
Sunil Jampa.
|
|
|
|
|
Hello,
This is the only way I can think of right now ,but I think you should select path as a root path for each drive that will take care of all the events unde.Have you try that.??
Regards ,
nishu
|
|
|
|
|
hi,
i am creating a editor in RichTextBox.
I want to create a pop-up menu when user clicks the Mouse Right button for copy,cut,paste.
can any one help me
Thank you
Prasad
|
|
|
|
|
Hello,
Use contexMenu from form controls.
Regards ,
nishu
|
|
|
|
|
hi,Nishu
wheather it is control in c#.
may i know the syntax pls
With Regards
Prasad
|
|
|
|
|
Hello,
Ya dear just drag and drop from form controls.
ContextMenuStrip
or create new
ContextMenuStrip cmenu = new ContextMenuStrip();
Regards ,
nishu
|
|
|
|
|
hi,Nishu..
I created a object of context menu
then how to add edit main menu to that one?
Thank You
Prasad
|
|
|
|
|
hi,
whenever i compile a project i want a form to be in the same position,when it is loaded.
User should not be able to move the Form at run time.
I set the Locked property to True still it can be moved at runtime.
Pls help me
Thanks
Prasad
|
|
|
|
|
Lock property works only in designer.
If you want to set the location, then get the event "LocationChanged" from the form, and every time the form moved, then set the location back to default location.
For example :
private void Form1_LocationChanged(object sender, EventArgs e)
{
this.Location = new Point(10, 10);
}
|
|
|
|
|
hi,
Thank you it is working
With Regards
Prasad
|
|
|
|
|
If you reset the location in the locationchanged event then you can see the form is moving to new position and then resetting to old position. But ideally form should not move at all at first instance. This could be obtained by trapping the windows message for form move. Try following code and it will not allow the form to move at first instance. However pls test the things after adding this piece of code..
protected override void WndProc(ref Message m)
{
const int WM_NCLBUTTONDOWN = 161;
const int WM_SYSCOMMAND = 274;
const int HTCAPTION = 2;
const int SC_MOVE = 61456;
if((m.Msg == WM_SYSCOMMAND) && (m.WParam.ToInt32() == SC_MOVE))
{
return;
}
if((m.Msg == WM_NCLBUTTONDOWN) && (m.WParam.ToInt32() == HTCAPTION))
{
return;
}
base.WndProc (ref m);
}
|
|
|
|
|