|
I am trying to pull data from a DB and have it prefill a form when the form is pulled up. Here is a little snippet of code that I am using. I am getting a handling error (in subject line)
public static string[] FormArgs;
public static DESClient.DESClientConnection conn;
private DESClient.DESApplicant applicant;
private string primedln = String.Empty;
int x = 0;
foreach(string arg in FormArgs)
{switch( x )
{case 4:
primedln = arg;
break;}
x += 1;
}
applicant = new DESClient.DESApplicant(conn);
applicant.setAppID(Convert.ToInt32 (primedln) );
lbName.Text = applicant.getLname()+", "+ applicant.getFname()+" "+ applicant.getMname()+".";
lbDLN.Text = applicant.getAppId() +"/"+ address.getState().ToUpper();
static void Main(string[] args)
{
Form1.FormArgs = args;
Application.Run(new Form1());
}
|
|
|
|
|
|
lbDLN.Text = applicant.getAppId() +"/"+ address.getState().ToUpper();
|
|
|
|
|
TWatson47 wrote: foreach(string arg in FormArgs)
{switch( x )
{case 4:
primedln = arg;
break;}
x += 1;
}
Why not just grab the fifth item by index ?
You need to step into this code, and work out which line is causing the error.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi guys,
I am trying to parse a date from a txt file using the following code.
while ( (sWhole = trd.ReadLine().Trim()) !=null )
{
if (sWhole =="" )
continue;
if(sWhole.EndsWith("=END="))
break;
String sDate;
Regex rDate=new Regex(".*\\d{2}/\\d{2}/\\d{4}\\s.*");
Match m5=rDate.Match(sWhole);
if (m5.Success)
{
sDate=m5.ToString();
scolDate.Add(sDate);
}
where scolDate=string collection.
When I run the file to parse the date, I keep getting an error saying "Index was out of range. Must be non negative and less than the size of the collection.
Please help!!!!
sasa
|
|
|
|
|
|
On second thought, if you don't know where in the text file the date is located, DateTime.TryParse may not work for you.
Have you looked at RegExLib.com[^]? The site is filled with hundreds of common regular expressions. Search that site for "date" and you'll get several hits.
Also, another tool that may aide you in regular expression building is the free RegExBuilder[^] tool. I highly recommend it.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: And in this corner, the Party of Allah
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
I prefer Expresso. It has dozens of useful features
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Not sure what is causing the "Index out of range"; but, your regular expression probably should be:
".*?\\d{2}/\\d{2}/\\d{4}\\s.*"
The "?" prevents the "*" quantifier from being "greedy".
- Bitwise
|
|
|
|
|
hi
How do i go about checking the format of the date that a user entered in a textbox? The date will be their date of birth. I want to make sure it is a valid date.
Please someone help me.
|
|
|
|
|
|
Judah Himango wrote: There are also regular expressions
I wouldn't like to try to write a regular expression that can check if a date is valid. Just the expression to check for the different number of days in the months would be horrific, not to speak of leap years...
---
b { font-weight: normal; }
|
|
|
|
|
I have a windows servcie application which has apart from OnStart,OnStop() only one more event and is FSWatcher_Created, where FSWatcher is FileSystemWatcher.In FSWatcher_Created eventhandler I have following code:
FileInfo file;
pathToWatch = ConfigurationSettings.AppSettings["PATHTOWATCH"];
//gets file name
fileName = Util.GetFileNameFromPath(e.Name);
//gets file path
filePath = pathToWatch+Util.GetFileNameFromPath(e.Name);
file = new FileInfo(e.FullPath);
MoveTo = ConfigurationSettings.AppSettings["PATHTOFILEMOVE"];
pathToMove = MoveTo+fileName;
if(file.Exists)
{
lock (m_SynLock)
{
file.MoveTo(pathToMove);
}
}
After installing I tested the service. When I drop a file in a designated folder(PATHTOWATCH) it immediately picks up and drops into another folder(pathToMove). If I now do the same second or third time with new file it does not move file to another folder.It seems that windows service somehow does not respond. Can anyone please explain this behaviour and tell me what should I do that it detects the new file and move to another folde?.
Thank you in advance.
Bharat Gadhia
In life, failures teach you as much as — or perhaps more than — successes.
Thank you very much for the help.
|
|
|
|
|
Wrap a try catch around your code and see if there exceptions. Also debug it in an exe project first until it works.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
hi all ,
I want to declar a varible (like int) as a golbal in Form1.cs.Can anyone guide me .
thanks .
s_mostafa_h
|
|
|
|
|
C# doesn't allow global variables. Every field is contained in a class. If you need global-like access, you can stick a static field in a static class:
public static class MyStuff
{
public static int MyVar = 15;
}
int val = MyStuff.MyVar;
To be honest though, if you're needing lots of globals, you probably have flawed design. I find static classes to be a rare need; you only truely need them for functions that have zero reliance on other classes, zero dependencies, and each function is completely self-contained with no side effects.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: And in this corner, the Party of Allah
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
I want to use it(this variable )in report Formula , is it possible ?
regards ,
s_mostafa_h
|
|
|
|
|
mostafa_h wrote: I want to use it(this variable )in report Formula , is it possible ?
A variable in a report's formula? Sure, so long as you can put the values into the formula from code, there's nothing stopping you from using a variable as input.
But I don't see how this relates to global variables.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: And in this corner, the Party of Allah
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
You can use it anywhere you like.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Using a global variable is not a good idea.
I think that it's better to use parameter objects rather than global variables.
For example if you have to pass x,y and z to a formula calculator you can have a object that gets x,y and z as parameters and then you can pass this object to a suitable metohd of your calculator.
In form1
<br />
public FormulaParams GetFormulaParameters()<br />
{<br />
FormulaParams params=new FormulaParams();<br />
params.x=int.Parse(this.txtX.Text);<br />
params.y=int.Parse(this.txtY.Text);<br />
params.z=int.Parse(this.txtZ.Text);<br />
return params;<br />
}<br />
In form2
<br />
public void Calculate()<br />
{<br />
Form1 form1=new Form1();<br />
form1.ShowDialog();<br />
int result=new Formula().Calculate(form1.GetFormulaParameters());<br />
}<br />
|
|
|
|
|
Hi
plz , read this :
public bool Chk1;
...
private void btnShowName_Click(object sender, EventArgs e)
{
if(CheckBox1.Checked)
Chk1=true;
sqlconn.Open();
da = new SqlDataAdapter(strQuery, sqlconn);
SqlCommandBuilder scb = new SqlCommandBuilder(da);
da.Fill(DS.MyTable);
crystalReport11.SetDataSource(DS);
ParameterField paramfield = new ParameterField();
ParameterFields paramfields = new ParameterFields();
ParameterDiscreteValue discreteval = new ParameterDiscreteValue();
paramfield.Name = "fieldName";
<big>discreteval.Value = Chk1 </big>;
paramfield.CurrentValues.Add(discreteval);
paramfields.Add(paramfield);
crystalReportViewer1.ParameterFieldInfo = paramfields;
crystalReportViewer1.ReportSource = crystalReport11;
sqlconn.Close();}
and Crystal Report , I create a parameter named :"fieldName" , and in Formula Editor , I wrote this :
Global booleanVar Chk1;<br />
if Chk1=true then {MyTable.FirstName}={?fieldName}
finally When I run the App. ,and I checked the CheckBox1, I have no report .
(I want if I checked the CheckBox1 , all record of FirstName field is Shown)
Where is My Wrong ???????
thanx a lot ,
Regards
-- modified at 3:41 Wednesday 16th August, 2006
s_mostafa_h
|
|
|
|
|
Well I'm not working with CR anymore
Global booleanVar Chk1;
I can't see where your Chk1 value(the one in formula editor) is assigned.
You create a ParameterDiscreteValue
ParameterDiscreteValue discreteval = new ParameterDiscreteValue();
and pass Chk1 value to it
discreteval.Value = Chk1 ;
but how can you tell the CR that this value should be assigned to your global variable?
It seems that something is missing.
I think that may be you should define a paramter named Chk1 and set its value.
|
|
|
|
|
surely , discreteval.Value = Chk1 is a value from Form1.cs .
if not , it doesn't work.
s_mostafa_h
|
|
|
|
|
is there any help ?.....
s_mostafa_h
|
|
|
|
|
I have a TabControl that is reordering the tabPages when I run the application. There are 10 tabs right now. In the designer, they are in the order I wish them to be. But, when I run the application, they change around a bit. I have tried adding a new tab, then remove it. Still broken. Weird.
Any ideas?
Kenny O'Dell
Prinicpal R&D Software Eng
Mettler-Toledo Inc.
Worthington, OH
|
|
|
|