|
Awesome! Glad it is working for you.
|
|
|
|
|
Well Spotted.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
JDM6763 wrote: _errorMessage = p.StandardError.ReadToEnd();
p.WaitForExit();
this sequence doesn't make much sense: ReadToEnd returns what is currently available without waiting, so waiting for the process end after that is meaningless. One way to fix things is first wait for end of process, then ReadToEnd on both streams. Alternatives with events or extra threads would allow to capture (lots of) output while the process is still running.
|
|
|
|
|
Perhaps this[^] might be of some use?
|
|
|
|
|
Thanks for the suggestion! What I need to do is fairly simple. I don't think it really needs to be this complex.
|
|
|
|
|
am a beginner in C# programing and i would like to write a program that will be able to register student' data by using Microsoft access for the database. thanks
|
|
|
|
|
Are you a beginner programmer, or just a beginner in C#? This is an important distinction.
The step you need to take before you even open up your code editor is to actually define your requirements. Start off by finding out what the user data is that you need to capture. It's pointless us giving you detailed help if you don't know what it is you are trying to capture. Work out what the business process is for capturing the data. For instance, is there an authorisation process? Does data have to be approved by an authorised user before it can be used elsewhere? Does it need any external interfaces?
While you are doing this, if I were you, I'd get a book on C# development and work through it. Pay particular attention to the sections on database programming - this is where you're really going to need to knuckle down and learn the topic. Also, you need to decide whether the data is going to be managed via a desktop application or a web application, and learn the ins and outs of those particular areas.
|
|
|
|
|
If you use a search engine to search the web for student database, you will find lots of useful information.
FYI: Questions as general as this do not go down well on The Code Project. It makes it look as if you have done no work yourself and you will get lots of messages telling you that no-one is going to do your work for you.
Once you have started coding your application and encounter a problem then by all means ask here. Remember to be specific, paste in error messages in full, if you get any. Include a code snippet for the section of code giving you problems and indicate the problem line(s).
Good luck.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
hi,
i used tab control in windows form , and i added five tab pages in tab control
,and i added 2 datagridview controls in each and every tab page and binding data for all Datagridviews
in From_Load Event .In Form Displayin with Filckering, so how to stop flickering for form loading.Could
you suggest me better way.
Regards,
Vishnu.
|
|
|
|
|
This[^] thread may help you.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Hi,
This is probably a design issue really. I have an object which is AbsMyObject (abstract). Now, what I am currently doing is testing what type it is, and passing it in to a method like this;
if (AbsMyObject is type1)
myMethod((type1)AbsMyObject);
if (AbsMyObject is type2)
myMethod((type2)AbsMyObject);
Im just overloading 'myMethod' so depending on what type my object actually is, a different method is called. Whilst this implementation works as expected, im ending up with tons of these "if object is" If statements and it just feels like a bad design. It also feels like this might have been encountered before and so there might be a better way of achieving this
Any pointers would be greatly appriciated!
Regards,
|
|
|
|
|
Hi,
Why not doing your tests inside your method ? This way, you wouldn't have to care about it when you call your method.
For example :
private void myMethod(AbsMyObject myObject)
{
if (myObject is type1)
{
}
else if (myObject is type2)
{
}
else
{
}
}
|
|
|
|
|
You're right - it sounds like an absolute design nightmare. If you just want to do something different inside your concrete implementation classes, why not rework it so that you use the same method for each implementation? That way, you completely remove the need to know about the implementation? By doing this, you will create a much more loosely coupled application.
|
|
|
|
|
What do you mean by 'abstract'? that it is an abstract class? Which I believe cannot be instantiated so is AbsMyObject of a type that inherits from an abstract class?
If this is the case the your absract class can identify a common function such as MyMethod. Then each of your inheriting class types can implement this function in its own way.
Then you can call function like so...
((AbstractClass)AbsMyObject).MyMethod();
...maybe I am misunderstanding what you are trying to do, if this is way off then please further explain what you are trying to achieve and what you are working with (class/type wise)
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Thank you all for your replies!
This is what I need in this case;
"If this is the case the your absract class can identify a common function such as MyMethod. Then each of your inheriting class types can implement this function in its own way."
I knew something was wrong with it but didn't quite know how to alter it. This works much better and each object can just have its own implementation of the method. My design skills are a bit poor at the moment
Thanks!
|
|
|
|
|
No problems also be aware that there an Interface is similar to a abstract class in what it may be used for. I don't know your exact requirements but if you don't know about Interfaces then you might want to check them out.
Here is a comparison between Abstract classes and Interfaces which may identify if you could make use of an Interface instead...
Abstract Class versus Interface[^]
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I'm just doing the schoolboy error check, so don't take this amiss, are you sure you haven't really got:
AbsMyObject.MyMethod();
I.E. The method really belongs in the AbsMyObject class rather than the caller?
Also I tried this (to make sure I wasn't about to make a schoolboy error ) and it works without the cast:
public abstract class Foo { }
public class Bar : Foo { }
public class Baz : Foo { }
public class Qux : Baz { }
public class Quux : Foo { }
class Program
{
static void MyMethod(string id, Foo arg) { Console.WriteLine("{0} Called Object Type {1}", id, arg.GetType()); }
static void MyMethod(Foo arg) { MyMethod("Foo", arg); }
static void MyMethod(Bar arg) { MyMethod("Bar", arg); }
static void MyMethod(Baz arg) { MyMethod("Baz", arg); }
static void Main(string[] args)
{
MyMethod(new Bar());
MyMethod(new Baz());
MyMethod(new Qux());
MyMethod(new Quux());
Console.ReadLine();
}
}
Sorry if I misunderstood your problem, but you are right, such if statements have a bad code smell. [Edit]: If those two options don't apply, Pete's suggestion is good. Can MyMethod be refactored to accept the base class and handle the class based differences inside it?
|
|
|
|
|
I think his issue is that he has an object type and therefore doesn't know the actual type of the object and cannot just call the method. For example...
MyMethod(new object());
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I think more complete code from the OP might help. I'm not sure I understand his question in that, I understand the problem that he needs to determine the type for a method call, but I don't know why he doesn't know it in the first place. I read the OP as all the types coming from some abtract base object.
|
|
|
|
|
musefan wrote: doesn't know the actual type of the object
The runtime will.
|
|
|
|
|
This would argue that he either needs an interface, or he needs to use generics instead. Basically, what he has here is a form of class factory, and there are lots of neat implementations that can be used.
|
|
|
|
|
I don't think that's necessary; did you try it without the casting?
But if you do need it, take a look here[^].
|
|
|
|
|
Hi
I'm trying to call a XP Mode shortcut programmatically, but I keep getting the same error message:
"problem starting C:\windows\system32\VMCPropertyHandler.dll The specified module could not be found"
I tried with the following:
string startPath = @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup";<br />
Process p = new Process();<br />
p.StartInfo.FileName = startPath + "\\XPModeInitializer (Windows XP Mode).lnk";<br />
p.StartInfo.UseShellExecute = true;<br />
p.Start();
But I have also done many variants. I even tried making a bat file, that just call the link. The bat file itself works when double-clicked, but when called from within my code like the following snippet, I get the same error message:
Process p = new Process();<br />
p.StartInfo.FileName = Environment.CurrentDirectory + "\\CallXPModeInitializer.bat";<br />
p.StartInfo.UseShellExecute = true;<br />
p.Start();
I also tried taking the shortcut parameters and using them myself like this:
string file = System.Environment.SystemDirectory + @"\rundll32.exe";<br />
string arguments = System.Environment.SystemDirectory + @"\VMCPropertyHandler.dll,LaunchVMSal ""Windows XP Mode"" ""||a9c104ed"" ""XPModeInitializer""";<br />
Process p = new Process();<br />
p.StartInfo.FileName = file;<br />
p.StartInfo.Arguments = arguments;<br />
p.StartInfo.UseShellExecute = true;<br />
p.Start();
But it produces the same error message,
I'm confused at to why a direct use of the bat file works, when the call to the bat file from within C# fails!?
How can I call a XP Mode shortcut from within C# code?
I'm in the high-fidelity first class traveling set.
And I think I need a Lear jet.
modified on Wednesday, December 1, 2010 4:35 AM
|
|
|
|
|
System.Environment.SystemDirectory
it self return the "c:\windows\system32\"
why are you aging adding the "system32" in your code ...
System.Environment.SystemDirectory + @"\system32\VMCPropertyHandler.dll,LaunchVMSal ""Windows XP Mode"" ""||a9c104ed"" ""XPModeInitializer""";
Rajesh B --> A Simple Programmer <--
|
|
|
|