|
In addition to Dave Kreskowiak's answer. OleDb also has "predefined" keywords. Sometimes you'll need to change column names or change the SQL to pass around this.
Just for info.
(PS: I don't think that's the case here btw)
V.
|
|
|
|
|
hey.. can anyone tell me that how can i convert files(doc,pdf etc) to UDF(universal disk formate) using .net libraries.. if not then is there any third party software tht does so.. doc to udf conversion ? i have checked out but found plenty of third party softwares that convert udf to other formats not ..other formats to udf ????plz reply otherwise i will be fired.. lolx
|
|
|
|
|
That makes no sense. It's like asking how to convert a doc file to a zip file. Or like asking how to convert a stack of paper to a suitcase. The paper goes inside, it does not "become" the suitcase.
What do you really want? Put files together in an UDF file? Or convert an ISO to UDF perhaps?
|
|
|
|
|
hmm thanks.. iso to udf.. regards
|
|
|
|
|
Ok, I don't know of any .NET libraries that will help you with that.
|
|
|
|
|
and wht about the third party softwares ?
|
|
|
|
|
Nero can definitely do it, I thought MagicISO too but I'm not very sure about that one.
|
|
|
|
|
hmm ok thanks.. very much..
|
|
|
|
|
Hi everyone,
I'm having trouble with the Application.DoEvents() in my c# application.
The application is for setting up a measurement with an oscilloscope and reading the data.
I have a loop, doing roughly this:
SetupHardware();
while(this.Run == true)
{
Application.DoEvents();
StartMeasurement();
ReadData();
AddDataToGraphControl();
}
I added the "Application.DoEvents()" because the user can change instrument settings with a form, and the controls' events need to be handled for that. Also the "Stop" button sets the global boolean "Run" to false.
Since the Application.DoEvents() doesn't seem to handle ALL pending events (I'm probably doing something wrong here, but that's another story), I started googling about Appication.DoEvents(), and found that I should avoid using it, and use multithreading instead.
I'd like to believe that, but I think in this case the use of Applicaition.DoEvents is the best practice here...
Can someone shine some light on this? Am I correct in thinking this is an exception to the "don't-use-DoEvents()" rule? How could I approach this using multitheading (which I haven't used before)?
modified 7-Feb-12 5:36am.
|
|
|
|
|
DoEvents is rarely the correct approach, and I don't think this is an exception. What you should do is have a thread which handles the instrument I/O (well, I, in this case ) and fires events which the main thread hooks up to:
class InstrumentThread {
Thread t;
public event EventHandler<InstrumentEventArgs> DataReceived;
public Thread Thread { get { return t; } }
public InstrumentThread(){
t = new Thread(Run);
}
private void Run(){
while(running){
StartMeasurement();
ReadData();
DataReceived(new InstrumentDataEventArgs(data));
}
}
}
class InstrumentEventArgs : EventArgs {
SomeType Data { get; private set; }
public InstrumentEventArgs(SomeType data) { Data = data; }
}
class MyForm : Form {
public MyForm(){
it = new InstrumentThread();
it.DataReceived += InstrumentDataReceived;
it.Thread.Start();
}
void InstrumentDataReceived(object sender, InstrumentEventArgs ea){
if(InvokeRequired) {
BeginInvoke(new EventHandler<InstrumentEventArgs>(InstrumentDataReceived), new object[] { sender, ea });
return;
}
AddDataToGraphControl(ea.Data);
}
}
|
|
|
|
|
Thank you for your reply. I'm still struggling with the instrument setup (setting vertical range, timebase, etc).
These settings should (to maintain a decent framerate) only be written to the instrument when the user changes a setting on the form. And on a fixed position: before StartMeasurement() (well, most importan is not between StartMeasurement() and ReadData(); that would cause problems).
I could ofcourse do:
NumericUpDown_VerticalRange_ValueChanges(Object sender, EventArgs e)
{
this.InstrumentSetupChanged = true;
}
and then in the InstrumentThread's Run method use
private void Run(){
while(running){
StartMeasurement();
ReadData();
DataReceived(new InstrumentDataEventArgs(data));
}
}
But I doubt working with this flag is a proper approach?
|
|
|
|
|
I'd have no problem with that, though normally I'd push messages onto a queue or something and then clear it where you put your comment. But if the message is just 'do something' then a flag is fine.
|
|
|
|
|
Application.DoEvents() is evil and should be avoided at all costs. You cannot seriously mention it and "best practice" in one and the same sentence.
A long winding operation needs to be handled in a separate thread; that is the way to keep your GUI operational, and to preserve a normal user experience. Often a BackgroundWorker comes in handy, as its ProgressChanged event fires on the GUI thread.
There is one alternative, and that is based on a timer, i.e. one operation (measurement) gets executed per timer tick. I am wondering about your setup, does it run "as fast as it can"? I see no code that synchronizes to a clock?
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
As stated in my reply to BobJanova, i don't use DoEvents() because of a "normal user experience", but because that is the moment I want to handle the instrument-setup events.
My application is an pc-scope application, so indeed it runs "as fast as it can".
|
|
|
|
|
The problem with DoEvents is that you're not just handling your instrument events. You handling ALL events, including your form controls and repaint commands. So if the use clicks a button a second time when they're not supposed to, or changes text, or moves the form, or whatever, those events get handled right along with your instrument events.
DoEvents processes all pending event messages until the message queue is empty. This opens you up to reenterant code possibilities where your code is not written to handle it.
|
|
|
|
|
Just to add to what Dave said, I'm not sure I would trust a scope (PC based or not) that ran "as fast as possible" - that implies that other events in the system are controlling or affecting the sampling rate. Which means that what I see on the "screen" may not be consistent and repeatable. I would much, much rather have a scope that had a slower, known speed so that artefacts become more obviously scope related than hardware.
I have spent too much time trying to find the source of a problem that turned out to be due to variable sampling frequency rather than a hardware or software problem in the target.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Oh, don't worry about that. I use real oscilloscope hardware. So on StartMeasurement(), the instrument is armed, waits for a trigger, and then fills the acquisition record with samples that are captured on a sampleclock. When the measurement is finished, I read the whole record from the instrument's memory to the PC, and re-arm the instrument. So running "as fast as possible" has no influence on the sampling rate.
|
|
|
|
|
Hello,
Am new in Programming and i chose to start with C#. I have an application that am building but am unable to connect my 'Add a member' form to a MySql database. I have created text boxes for first name, last name, phone, city and down there an ADD and CANCEL buttons.
Could someone please give me the code to link the add button to the database such that the information on the text box is sent to the database. Please help out like you doing it to a two year old.
Thanks.
|
|
|
|
|
Member 8624435 wrote: Am new in Programming and i chose to start with C#
Good choice.
Member 8624435 wrote: Could someone please give me the code to link the add button to the database
Nobody will GIVE you code. What did you try? How did you search? Maybe you need other keywords. Try this site[^] for starters. In addition, you don't link the ADD button to the database directly. read up on 'n-tier applications' and you'ld probably want a book to start with.
Member 8624435 wrote: Please help out like you doing it to a two year old.
My son is nearly two, he cannot read or write yet, let alone program. We assume you have a certain level of intelligence.
In summary:
- Start with a book and read it from first to last page.
- Don't post anything like 'give me code' and the likes. You must do the effort. people here only guide or advice you.
- The tone of your question is wrong and might be downvoted by others. (just for info)
Hope this helps.
V.
|
|
|
|
|
Rather than asking for the code you should try doing some research, try typing your question into a google search. Any basic question will have been answered 1000s of times and you can use them to begin your research.
Do not rely on this as your only source of knowledge, buy a book, it will give you some structured learning.
When you have a specific problem with something then come back with the code that is giving you a problem and you'll find this site much more useful.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i want to access my other forms when i click the button from one form.... can anyone tell how to access the other forms in c#.????
|
|
|
|
|
You can use delegates to communicate between forms.
Here[^] is a decent example.
|
|
|
|
|
Well there are multiple methods. Another approach can be
- make a static class and define its data/function members
- set values of data member of this class from Form2.
- access this static class in Form1.
- Before setting (or after getting) values, you can clear all the values of static class.
It all depends on situation. Once delegates did not work for me so had to use this method
|
|
|
|
|
thanks for your useful info....
|
|
|
|
|
A key piece of information here is how the Forms are created. If there is one primary Form that creates, and Shows, the other Forms, then, at the point where you create the secondary Forms, you have a reference to that newly created Form.
That means that if you do this in your main form:
Form2 F2 = new Form2(); And you define the variable 'F2 as being within the scope of the main form: you can always access the instance of Form2, 'F2, within the main form: once you have instantiated it ... most likely in the main Form Load EventHandler.
The question that you should be asking yourself now is: "wait a minute, 'F2 has a TextBox on it, and that TextBox is an access-as-private-only Control: it can't be seen using the reference to 'F2: this won't work:
Form2 F2;
TextBox TextBoxOnForm2;
private void Form1_Load(object sender, EventArgs e)
{
F2 = new Form2();
F2.Show();
TextBoxOnForm2 =
} And this is the point at which I encourage you to start thinking about the issue of "what is the bare essential content, or control, that one Form needs to access from another ?: does it need to only access content in the Control, or does it need access to the Control itself so that it can modify the content of the Control, and/or its settings, or visual appearance, or whatever."
In this case it appears you want access to either a TextBox itself implying you might want to both read from and write to the TextBox perhaps make changes to its structrure: probably, at least, access the contents of the TextBox.
Let's take the case where you want full access to the TextBox on the instance of Form2, 'F2:
1. first define a public property in Form2 of Type TextBox:
public TextBox F2TextBox
{
private set;
get { }
} 2. then in the Load or Shown events of Form2: set that public property to the instance of the TextBox: so your code in Form2 might look like this:
public TextBox F2TextBox;
private void Form2_Load(object sender, EventArgs e)
{
F2TextBox = textBox1;
} And now in your main form, you no longer need to keep a reference to the whole instance of Form2; you just need access to the TextBox on Form2:
public TextBox TextBoxOnForm2;
private void Form1_Load(object sender, EventArgs e)
{
Form2 F2 = new Form2();
F2.Show();
TextBoxOnForm2 = F2.F2TextBox;
} Now you have access to the TextBox itself: you can manipulate its Size, BackGroundColor, whatever, an access its Text by TextBoxOnForm2.Text
And if you want to get the current content (Text) in the TextBox on F2 "on demand," for example,, by a Button Click EventHandler on the main form:
private void button1_Click(object sender, EventArgs e)
{
SomeTextBoxOnForm1.Text = TextBoxOnForm2 .Text;
} What if you need to instantly synchronize any change in the Text on F2 with other Text somewhere on the main Form: then you are going to have to define a Public Event that accesses F2's TextBox, and Raises that Event with each change in the Text in the TextBox on the instance of Form2: the main form will then have to "subscribe" to that Event. The answer above by Abhinav points you to the use of Delegates to help you with that.
There are other ways, also, to approach "access to control and/or data" between Forms, like the use of Interfaces, and Static classes.
And we could re-write this example so the only thing you could get access to on Form2 was the actual Text content of the TextBox, not the TextBox itself, but we'll leave that for you to think about. But, here's a hint: the public Property defined on Form2 is now going to look something like this:
public string F2TextBoxText
{
set { textBox1.Text = value; }
get { return textBox1.Text; }
}
"The first principle is that you must not fool yourself, and you are the easiest person to fool." Richard Feynman
modified 8-Feb-12 9:36am.
|
|
|
|
|