|
Personally, I would read the documentation of Thread and ThreadStart.
And then I would use the Thread pool instead.
|
|
|
|
|
I'm not sure I understand. Your MyDelegateType has the same signature as the Framework's ThreadStart delegate
If the signature of your thread's method is changing, maybe using a lambda would help:
new Thread( _ => ThreadMain( ... parameters ... ) );
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
Thanks for your answers, I'll have a look at it
|
|
|
|
|
Hello people, My client wants to have an app which will automatically download excel 2003 attachments from emails and store it into the database.
At the moment I have designed an app in C# which reads excel sheet by browsing to it from the local machine and then displays contents into the GUI.
Is there any way in which I can automate this process..
Cheers!
|
|
|
|
|
Here's A POP3 Client in C# .NET[^] a good link to get you started on the emails. look at the last codeblock for attachment retrieval.
If it' stuck, DO NOT pull harder!
|
|
|
|
|
If you're using Outlook you could write a small add-in and hook onto the mail received event. This would then start a process to check the received message, check for attachments and do any further processing required.
I assume you're talking about holding the actual file in the database - it might be a better idea to save the files on a drive and write a reference to the path in a table somewhere.
It definitely isn't definatley
|
|
|
|
|
Yea am using outlook 2003 to receive emails from clients. The emails contain the Excel sheet with a fixed format. Could u elaborate on how it would be possible to write a reference to Outlook using C#, so that application click even can check for new attachments and download it.
|
|
|
|
|
It's a couple of years since I've done this and don't appear to have anything directly relevant to hand. However, you'll be best doing some research into Visual Studio Tools for Office (VSTO - there's some good articles here[^]) as well as the Outlook object model (try here[^]).
In summary, you'll create an Add-in for Outlook using VSTO. This add-in will register as a listener with the NewMailEx event (mail received) and once the event is fired, the add-in will examine the new mail to determine whether or not is has any attachments and if any of these are excel documents.
From here the rest of your task should be fairly trivial; either you'll copy the file to a folder somewhere and execute a stored procedure to write an entry into a database table somewhere or you'll stream the file directly into the database (depending on what method of storage you use).
A quick google will bring up a stack of articles; I remember in the past having some trouble deploying Office 2003 add-ins but think they were mostly resolved by ensuring that VSTO was installed on the client machine (free download from MS[^])
Sorry I don't have anything more specific but with a little bit of research you should be able to find your way.
HTH
It definitely isn't definatley
|
|
|
|
|
I've just re-read this; it sound like you're wanted to copy the contents of the excel file into a database table. If you know that the format of the file is going to be identical each time, I'd suggest creating a DTS package using integration services and executing this, passing in the name of the file as a variable. If it's not identical you might struggle - it's non-trivial at any rate.
It definitely isn't definatley
|
|
|
|
|
The name of the Excel File varies, but the sheet has fixed columns & column names. Data appearing in the column varies.
|
|
|
|
|
In which case you should be able to build a simple DTS package and execute it from within the add-in. I've not really got enough room to explain here but there's plenty of articles and the SSIS newsgroups have some pretty comprehensive examples.
It definitely isn't definatley
|
|
|
|
|
Hi guys,
What I'm trying to do is cut copy and paste the selected text from any text box in my application. I have it working if it copies the entire text from the box, and I have it working if I hard code the text box name into to function.
Ive looked all over for an answer to this, and have got nowhere
This is the current code I am using:
string ActiveCon = this.ActiveControl.Name;
string SelText = ActiveCon.SelectedText;
Clipboard.SetText(SelText);
this.ActiveControl.Text = "";
It just does not like SelectedText used on a variable
Any help on this would be greatly appreciated.
Regards
Martin
|
|
|
|
|
TextBoxes don't have a SelectedText property, I believe that this is limited to RichTextBoxes. There's also a Copy [^] method that does what you want
I are troll
|
|
|
|
|
Sorry to correct you eddy but TextBox's do have a SelectedText property.
jason
|
|
|
|
|
|
You're welcome Eddy
|
|
|
|
|
Why are you using a string for the active control?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi,
You can't just get directly to a TextBox when all you know is its name.
Here is a little snippet that would do something akin to what you want, assuming your class
is a Form or whatever Container that is holding the TextBoxes:
public string GetTextBoxText(string name) {
string text=null;
foreach(Control c in Controls) {
TextBox tb=c as TextBox;
if (tb!=null && tb.Name==name) text=tb.SelectedText;
}
return text;
}
BTW: If some of your TextBoxes are located deeper in the Control hierarchy, you would have to adapt for that.
PS: as Dave said, if you would hold a reference to the ActiveControl, rather than just holding its name, you could get to its text right away!
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Does anyone know the best way to store and access thousands of abbreviations which are stored in a db and output the full string. For example Intel's stock symbol is INTC. When i read INTC from the db i want to set string str to Intel Corporation so the full name can be displayed to the user. currently the full string is not stored anywhere, just output on the fly based on the abbreviation and a million if-else statements
ie.
if(abrev.equals("INTC")) str = "Intel Corporation";
else if(abrev.equals("GOOG")) str = "Google Inc";
....
....
Obviously the wrong way to go about it. Should the full name just be added to the db? could create hash table with abbreviation as key and full string as value. Yes the if-else method works but is awful to look at and hilariously bad. Thanks guys and gals
|
|
|
|
|
MagForJ wrote: Should the full name just be added to the db?
I would say stroe it in the db itself and use a dictionary to find the mapping.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
As an easy alternative, just make it into a switch.
|
|
|
|
|
Hi
As you already mentioned store the abbrevations and the long name in the db. I would suggest using a second table, so that you can use a nested select statement to get the full name. This will enable you to use the full performance power of your relational database.
Regards
Sebastian
|
|
|
|
|
Use Dictionary<string,string>. The code can be the key. This
e.g.
Dictionary<string,string> companies = new Dictionary<string,string>();
companies.Add("INTC", "Intel Corp");
....
string companyName= companies["INTC"];
Note that you can only have one code entry, but the same company name can appear next to multiple codes.
|
|
|
|
|
I don't know why this bugged me, but it does.
MagForJ wrote: if(abrev.equals("INTC")) str = "Intel Corporation";
else if(abrev.equals("GOOG")) str = "Google Inc";
Why abbreviate "Incorporated" in "Google Inc" but not "Corporation" (Corp) in "Intel Corporation"?
|
|
|
|
|
I'd definitely make it data-driven if I were you. Whether or not you should just add a column to an existing table is another matter.
In this particular case I think I'd have a look to see if I could get the data from somewhere and go from there. For example, there may be a free web service that let's you retrieve this. (This could be done at run-time, but web services are quite slow though; you probably don't want to look up a code at a time for a collection, for example.)
If you can get the data, storing it in a new table has some benefits: The descriptive string can potentially be sizeable, and adding a large column to any table, especially a small table (I've no idea what row sizes you have here), can have a significant impact on row size and thus on performance. I don't know what DB you're working with, but SQL Server has 8K pages and yet I've seen a "transaction" table (storing financial transactions, not database transactions!) that had a column defined as nvarchar(500) - that's a 1000 bytes just for this one column. That table could have millions of rows, but SQL Server couldn't get more than 6 records per page thanks to this horrible design error.
However you store the data, if it's not too substantial and you need raw speed, load it into a cache once and you should get great results.
|
|
|
|