Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I developed a desktop application in C# 4.0 with Oracle 11g & used Crystal report for VS 2010

it executing & running fine in developement machine & i created a setup file

In client system i installed oracle client and setup file of my application

able to use the application well until i generate any crystal report

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at System.String.Substring(Int32 startIndex, Int32 length)
at Visitor_Management_System.VisitorIDReportWindow.VisitorIDReportWindow_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

2nd even if i click continue its asking me server username & password

when searched in net, there are ideas to declare the name & password in coding so i modified coding for CrystalReport's Form Load_event like below but no use
private void VisitorIDReportWindow_Load(object sender, EventArgs e)
{
if (this.CON.State.Equals(System.Data.ConnectionState.Open))
{
CON.Close();
}
CON.Open();
DataTable DTB;
string query1 = "Select * from VMS_VISITOR where PASSNUMBER ='" + VisitorCreationWindow.PNBR + "'";
using (OLCMND1 = new OracleCommand(query1, CON))
{
using (OADAP1 = new OracleDataAdapter(OLCMND1))
{
DTB = new DataTable();
OADAP1.Fill(DTB);
}
}
RDT = new ReportDocument();
string reportpath = System.Windows.Forms.Application.StartupPath.Substring(0,System.Windows.Forms.Application.StartupPath.Substring(0,System.Windows.Forms.Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\"));
reportpath += @"\VisitorIDReport.rpt"; //string reportpath = "D:\\Visitor Management System\\Visitor Management System\\VisitorIDReport.rpt";
RDT.Load(reportpath);
ConnectionInfo connectioninfo = new ConnectionInfo();
connectioninfo.DatabaseName = "ORCL";
connectioninfo.UserID = "itapps";
connectioninfo.Password = "it123";
Logindetailforreport(connectioninfo,RDT);
VisitorIDCrystalReportViewer.ReportSource = RDT;
RDT.SetDataSource(DTB);
}
And for exception i am not able to get any idea..
Posted

1 solution

Quote:
System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
I think you're messing something on this line, correct it.
C#
string reportpath = System.Windows.Forms.Application.StartupPath.Substring(0,System.Windows.Forms.Application.StartupPath.Substring(0,System.Windows.Forms.Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\"));

Quote:
2nd even if i click continue its asking me server username & password
Check this answer
Crystal Report Login Prompt[^]
Quote:
when searched in net, there are ideas to declare the name & password in coding so i modified coding for CrystalReport's Form Load_event like below but no use
Make sure you did right.
C# Crystal Reports Dynamic Logon parameters[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900