|
+5 for saying 'odd's are', we don't need another thread like in the VB forum...
|
|
|
|
|
I am trying very hard to be nice, and to be helpful. I see he's not responding. I bet he just asks the same question the same way in a week from now
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
No no, he just ran off to the nearest book store.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
Assuming you have placed the buttons on your form, double click them and the appropriate event handlers are created in the code. You can now enter code into these handlers to cope with them.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I'm really stuck here. I have been Googling this all day and no luck.
I'm working in a C# WinForms app that reads data from Excel into a DataSet. Here's the SQL:
string Query = "SELECT [TPMA Run Date],[Buyer],[Item],[PO Number],[PO Line],[PO Due Date],[Date Required]," +
"[New Date],[Status Comment],[Status Code],[Prior Week New Date],[Prior Week Status]," +
"[Prior Week Status Code],[SEQNUM] FROM [Current MRP Action Messages$]";
If I change it to this, it works fine:
string Query = "SELECT * FROM [Current MRP Action Messages$]";
Here's my conn string:
ConnectionString = @"provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileName + ";Extended Properties=\"Excel 8.0;HDR=NO;IMEX=1\"";
The Excel file has column headers in the first row.
Anyone know what's wring here?
Everything makes sense in someone's mind
|
|
|
|
|
Hi,
I haven't done this with Excel but here are my thoughts anyway:
- if "SELECT * ..." works fine, then your connectionstring, DB path, etc. are fine;
- so the problem must be in one or several of the field names
Hence: start with one field, then add them one by one until it fails; fix that, and keep adding till done.
BTW: I would never choose complex field names with spaces, dollars, etc; it only complicates matters. However escaping them would solve everything, I am not absolutely sure square brackets is the right way, I found at least one web page claiming backquotes should be used. Once more, experiment with a single column first.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
I really have no idea with excel, but:
If the Select * works fine, then examine the datarow(s) returned and find the name(s) of the columns returned - that will show you what names of columns you need to use in your select statement.
Try reducing the first Select to just returning one column - if that works add the next column and keep going until it breaks.
My suspicion is that the excel data provider is not using the first row for column names, hence it can't find them in your first query - so you need to find out how to tell it to treat the first row as names of columns.
Good Luck
Max
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
I wrote a windows application witch should run always - from turning on the computer until it goes off. When I try to shut down the computer sometimes it doesn't turn off. My OS is Windows-XP.
(I have some threads but all of them are background threads.)
|
|
|
|
|
You're cancelling the FormClosing [^] event? Take a look at the CloseReason; you might want to allow the closing of the form when the CloseReason is CloseReason.WindowsShutDown
I are Troll
|
|
|
|
|
Thanks, you're right I did cancel the close.
|
|
|
|
|
If you want an application to run from start to end like this you should use a Windows service, not a Windows form application, then you won't have this issue.
only two letters away from being an asset
|
|
|
|
|
Thanks for your help.
Now I got some error/strange window with caption:
.Net-BroadcastEventWindow.2.0.0.
What does it mean?
Thanks.
|
|
|
|
|
I want to remove a bottleneck using a second thread, but my thread dies but the object lives on..
So i don't seem to understand whats going with my thread let me try to explain:
Starter code:
<br />
msnthread = new Thread(new ThreadStart(StartMSN));<br />
msnthread.Start();<br />
Function code:
<br />
private void StartMSN()<br />
{<br />
start:<br />
try<br />
{<br />
if (Process.GetProcessesByName("msnmsgr").Length != 0)<br />
{<br />
Msnclass = new MSN();<br />
Msnclass.Cout += new MSN.cout(Cout);<br />
}<br />
else<br />
{<br />
Thread.Sleep(10000);<br />
goto start;<br />
}<br />
}<br />
catch (Exception e)<br />
{<br />
Cout("Fatal error: \n" + e.Message);<br />
Thread.Sleep(10000);<br />
goto start;<br />
}<br />
}<br />
After this code has run, the thread dies but the Msnclass keeps alive, but is it still threaded??
What am i doing wrong, also what would be a better way to restart instead of the goto start?
Thanks!
modified on Monday, October 19, 2009 6:23 PM
|
|
|
|
|
Hmm.
[EDIT]a finally block would always execute, resulting in one sleep too many. fixed that with a variable delay which also makes the finally block unnecessary
[/EDIT]
the normal way for retrying something is by setting up a loop which gets exited on success only. For instance:
for(int delay=0; ; delay=10000) {
Thread.Sleep(delay);
try {
...
break;
} catch(...) {
...
}
}
so no goto's, and a single sleep.
Scalee wrote: Msnclass.Cout += new MSN.cout(Cout);
I'm puzzled by this statement. Not sure what the intention is.
I'm pretty sure the cout should be a Cout (public identifier ==> PascalCase).
And it would be my guess cout() never returns for some reason.
suggestion: add a log statement right behind it; if that never executes, look at cout().
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
modified on Monday, October 19, 2009 6:00 PM
|
|
|
|
|
Aah no :P
You can ignore Cout it's an event, i can fire the event from the Msnclass and send messages to my main class to be printed
The thing still is that my thread dies and my object keeps existing which should be impossible...
Ill add some comments to the main thread if i still can.
|
|
|
|
|
OK,
I read it again, here are some comments and suggestions:
1.
please use PRE tags, not CODE tags, for showing multi-line code snippets.
2.
//check if msn is running if not abort isn't really accurate, as nothing gets aborted, something gets retried instead.
3.
assuming Cout(string) logs or somehow shows a string, add a Cout("going to create MSN") , a Cout("done creating MSN") and Cout("going to sleep") at the appropriate places. That way you will easily see what goes on.
4.
I expect you'll see the "going to create MSN" but no "done creating MSN", as the only location the loop can hang seems to be inside the MSN constructor, for reasons unknown as you didn't show its code.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
Nope, there is no hanging.
This is how the application should be:
Main thread > running > mainform
Msn thread > running > msn class
What it is:
Main thread > running > mainform
Msn thread > stopped > msn class
Yet the class is still alive and usable, this is how i checked it:
toolStripMenuItem6.Text = "Msn status: " + msnthread.ThreadState.ToString();
toolStripMenuItem6.DropDownItems.Clear();
foreach (MsnWindow win in Msnthread.MsnWindows)
{
toolStripMenuItem6.DropDownItems.Add(string.Format("{0} {1} {2}", win.Name, win.History.ToString(), win.Window.HWND));
}
|
|
|
|
|
So there is no problem at all:
the MSNstart method has run to completion, hence the thread is stopped.
and the MSN object may be collectible (if no reference got stored somewhere by its constructor), and hence could possibly be collected by the GC the next time it runs.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
Dear Sirs,
I need my project files to go to the right place. I currently have three projects. Project A depends on Projects B and C, both Class Libraries. Project B has a database file (MDB) in it, which copies properly to Project A's output (either Release or Debug \data) directory. Project C, however, the rogue, has a file in it and it copies to project C (!!)'s output folder. How do I get Project C to cooperate, and send its file (an XNA font file) to Project A working directory?
I wouldn't mind so much Project C copying its Content files to its own directory, but it can't find them from there: when the program runs, Project C uses Project A's active directory, so Project C complains, I can't find my file. I look around, and in Project C's directory, there it is, but the Exception says that it's looking in Project A's active directory.
I hope I have been clear enough. Thanks in advance for your help.
In Christ,
Aaron Laws
In Christ,
Aaron Laws
http://ProCure.com
|
|
|
|
|
In Project C's properties, go to Build Events tab and use a post-build event command to copy the files to the necessary location.
only two letters away from being an asset
|
|
|
|
|
Dear Mr. Nischalke,
Thank you for your prompt reply. I noticed, however, that Project B (the working project which properly copies its database) doesn't have what you described. Why can Project B work and not Project C?? I'll try your suggestion.
In Christ,
Aaron Laws
http://ProCure.com
|
|
|
|
|
I can only assume that VS know to copy the file as a dependency when you add a reference to the project. The properties of the file are probably set to copy to output.
only two letters away from being an asset
|
|
|
|
|
Dear Mr. Nischalke,
Thanks for you help. In both projects, B and C, the files in question are set to
Build action | Content
Copy to output directory | True
In Christ,
Aaron Laws
http://ProCure.com
|
|
|
|
|
If you want further help, drop the Mr.
I've used commands like this to move files within my project folder structure
copy "$(TargetDir)$(TargetFileName)" "../../../Common/$(TargetFileName)"
only two letters away from being an asset
|
|
|
|
|
Hi,
Dll files may be copied to the output directory by setting the Copy Local property of the reference (right click the appropriate reference in solution explorer).
In general any file may be copied by right clicking, selecting properties and setting the Copy to Output Directory property.
Alan.
|
|
|
|