|
I Solved the probem, I realized after you wrote the above the control I am accessing is the original not the copy I added to my form, so I did the following in the form:
this.ctrlMainControl1.numericUpDownAccount.Value = nAccountID;
this changes he value of the copy of the control not the original control.
Thanks,
Michael
|
|
|
|
|
I have questions to ask about the following C# 2008/2010 code listed below:
Process eProcess = new Process();
eDataContext rData = new eDataContext();
string[] PkgIDs = rData.Trans.Select(c => c.Package_ID ).ToArray();
foreach (string PkgID in PkgIDs)
{
eProcess.StartInfo.FileName = "app1.exe";
eProcess.StartInfo.Arguments = "10 " + " 5" + PkgID;
eProcess.Start();
eProcess.WaitForExit();
eProcess.Close();
}
My questions are the following:
1. After the
eProcess.WaitForExit();
line of code is finished waiting for the process to finish executing, is there a way to check for the condition code returned from the run. I basically want to see if the job that executed ran successfully.
If so, can you tell me how to setup that code?
2. Do I need the line of code
"eProcess.Close();"
Why or why not?
3. I am basically looping thoough calls executing a process based upon values received in PkgID that is stored in a database table. Is this code good or not? Can you tell me why or why not? If the code is not good, can you tell me a better way to
write the code?
|
|
|
|
|
Did you happen to read the documentation on the ProcessClass??
There's a little property called "ExitCode" which will contain the exit code of the process once it terminates.
You don't need to call Close. It'll be called by the Process class Dispose method automatically, which you SHOULD be calling when you're done with the Process object.
You might want to wrap that process code in a using block to take care of this for you.
|
|
|
|
|
Hi,
I am coding a utility that will ping a computer name given by the user. If ping succeeds, I need to open C$ in Windows Explorer for that computer (\\computername\c$). I expect Windows to prompt for credentials if it is able to successfully find that path.
I have ping working properly. What do I need to do to open C$? I have been searching for awhile and haven't ran across a good example so far.
In vbscript, I would shell out and run the command 'start "" /wait \\computername\c$'. There must be a way to accomplish this but I'm not having much luck in finding the solution.
Thanks,
Rob
|
|
|
|
|
Use the Process class.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Yeah, as Eddy said, but why bother pinging first? It seems a needless step.
|
|
|
|
|
I guess pinging isn't really necessary with the proper error handling in place. It might make the app a little faster too.
I haven't looked at the Process class but the example below seems to work:
System.Diagnostics.Process.Start("explorer", "file://PROG2/");
If I just drop the ping part out of there and attempt to connect to C$ on a network client computer without testing via ping first, there is a 50/50 chance that it will be able to succeed. What is the best way to handle this scenario if the client is unavailable?
modified 7-Sep-12 17:02pm.
|
|
|
|
|
I was using ping to verify that the computer was on the network before attempting to open the C$ share. If I try to open the C$ share and the computer is not on the network, the application will fail without some way of dealing with the error.
Could you give me some sort of idea what I should research (keywords or classes perhaps) in order to catch the error on the fly? I am new to C# and haven't found very many reliable resources to learn/research the language.
Thanks,
Rob
|
|
|
|
|
|
In a C# 2008 and C# 2010 desktop applications that I am working on, I have the following questions to ask about adding features to the app.config file:
1. I would like to know how to add a reference to an executable that needs to run. I do not want to hard code the path, I would prefer to have the data path be dynamic.
2. I would like to add 2 entires to the app.config file where the location points to two different locations where output files are placed.
Thus can you tell me and/or point me to a reference that will show me how to make the coding changes to use and app.config file and what to add to the app.config file for my goals to be accomplished? (I basically would like to know what ‘tag(s)’ in the app.config I would need to place these new references.)
|
|
|
|
|
Here is an article right here on CodeProject.
Read/Write App.Config File with .NET 2.0[^]
It should still work for future versions of .NET as well.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
The basic use of the config file is so your app can load data.
Presumably that is what you intend to do with the data once it is in there.
However ignoing how you add it to the config file, exactly when do think you are going to do this?
|
|
|
|
|
You can store paths in app.config file that you can change after installation of the application:
<configuration>
<appSettings>
<add key="path1" value=""/>
<add key="path2" value=""/>
</appSettings>
</configuration>
After installation of the application app.config is renamed to <projectname>.exe.config. So you need to change your settings in this file.
You can store paths in app.config file that you can change after installation of the application:
<configuration>
<appsettings>
<add key="path1" value="">
<add key="path2" value="">
After installation of the application app.config is renamed to <projectname>.exe.config. So you need to change your settings in this file.
|
|
|
|
|
Based upon your statement,
string[] names
= context.Customers.Select(c => c.Name).ToArray();
How would I change this statement to mean the following from the sql?
select customer_id from Customers where customer_received_date is not null
|
|
|
|
|
Well, I would change it to use the more natural (to me anyway) way of doing LINQ like this:
string[] names = (from p in context.Customers
where p.customer_received_date != null
select p.customer_id).ToArray();
|
|
|
|
|
There is no technical problem or error in my project.
This question is about how improve my project to be more user friendly.
Let me explain about my project:
There are many tables in DB and I have created a CRUD Form for each table; There is Form that contains some buttons and every button opens a single CRUD Form.
Now imagine that user want to register an student and the user is very busy because of large number of students; so the user should open and close many of Form from the board just for entering a single student's information.
Do you have any idea to improve my project?
Meysam
|
|
|
|
|
Have separate "Save and Close" and "Save and add another" buttons?
|
|
|
|
|
You know that in DB there is a table for each existence.
Person, PhoneType, Phone, Register, Class, Teacher, etc; and for each of them there is a CRUD Form. If one of them will cancel so I would cancel all of the insertion before the current Form.
Did you get what I mean?
In other word I should update all of them if the last Form's DialogResult equals DialogResult.OK and reject all changes if it is DialogResult.Cancel.
Meysam
|
|
|
|
|
Meysam Tolouee wrote: Did you get what I mean?
No.
But now I get the feeling that what you have is quite dreadful. I'm glad you're trying to improve it.
|
|
|
|
|
Let's go forward step by step.
First the user will open and enter personal info about the first student in CustomerUI then he/she will close that. Now the entries will update at FormClosing by user's confirmation.
Second step the user is going to enter information about class registration. Now consider that the student doesn't want to register any more.
At thiss time there is a record in "Person" table in DB that is useless.
Was it clear?
Meysam
|
|
|
|
|
Meysam Tolouee wrote: I have created a CRUD Form for each table
That is a very bad idea; it's not how the user thinks of the task and the schema should not be so exposed to the user.
I also fear for what happens when the user deletes records improperly (not that delete should be allowed anyway).
|
|
|
|
|
I know and it is the reason that I want to improve my project for.
Meysam
|
|
|
|
|
Meysam Tolouee wrote: This question is about how improve my project to be more user friendly.
Have you considered asking your users[^]? Joel also has a nice article on dogfooding, well worth the read.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Sounds like you’re talking about a “transaction”.
Instead of multiple forms, it seems like a single form with multiple “tabs” of related information would be more effective.
Use the form to create a transaction for registering the student by first storing all data that is entered “locally”; in a local copy of the database or as XML on a local drive.
Cancelling the transaction is simple; you don’t commit to the “production” database and just delete the local copy.
If the transaction is complete and the student is to be registered, you post all the local data to the server in one step and then delete the local copy.
|
|
|
|
|
I like your idea and I am going to try it.
Thanks.
Meysam
|
|
|
|