|
Thanx it works 
|
|
|
|
|
I see from later messages that you got it sorted anyway, but there are a comments. Please do not assume I am "getting at you", I'm not - I'm just trying to make your life easier later on!
1) When you post code fragments, use the "code block" widget on the message entry page. This preserves the formatting and makes it easier to read. It doesn't make much difference with a tiny bit of code like yours, but any bigger and it really can improve things. There are people here who won't read tour code unless it is formatted - and they include some people who seriously know what they are doing!
2) Get into the habit of using "too many" curly braces - whenever you can use them do. Particularly in the early days, they make it a lot more obvious where the flow of control is going. If you don't then there is always the temptation to add a new line of code which is outside the scope you intended:
if (condition)
statement; becomes:
if (condition)
statement;
statement; and then you are wondering why the second one is always executed!
if (condition)
{
statement;
} becomes:
if (condition)
{
statement;
statement;
} Is a lot more obvious. (And yes, I know VS re-formats code automatically - but it doesn't always.)
3) You don't need the "objStream.Close()" - the using statement Disposes of the file stream, so there is nothing to close!
4) Try to be consistent with your naming: lblerror and lblDispaly can't both be right! Use lblError and lblDisplay instead. Remember that VS will rename variables for you if you ask it nicely...
5) Use names that describe what something does, not what it is: objStream is neither helpful nor accurate! srInputFile is a lot more useful when you come back to it in six months time.
6) Try to declare things in a minimum scope: for example:
StreamReader objStream;
string myfile = Request.QueryString["txtreader"] + ".txt";
string reading = Server.MapPath(myfile);
string[] lines = new string[5];
using (objStream = new StreamReader(reading))
{
for (int i = 0; i < 5; i++)
{
if (!objStream.EndOfStream)
{
lines[i] = objStream.ReadLine();
lblDispaly.Text = lines[i];
}
}
}
objStream.Close(); Because objStream is only usable within the using block, declare it in the using block. That way, if you try to use it outside, the compiler will complain and you will realize there is a problem before you can run the code. Catching bugs in the compiler is way faster than at runtime!
string myfile = Request.QueryString["txtreader"] + ".txt";
string reading = Server.MapPath(myfile);
string[] lines = new string[5];
using (StreamReader objStream = new StreamReader(reading))
{
for (int i = 0; i < 5; i++)
{
if (!objStream.EndOfStream)
{
lines[i] = objStream.ReadLine();
lblDispaly.Text = lines[i];
}
}
}
objStream.Close();
This may seem a lot of criticism, but it's not really - it's just good coding practices (hopefully) explained as to why we do things the way we do! It really does speed things up when projects get more complex, and it's is worth getting right from the start, because that way you don't have "bad habits" to break later on.If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
Thanx, I will use the advice
|
|
|
|
|
Hi, I need to have maybe 5 threads running which all use the same DataSet and need to loop through all the rows retrieved but each row must be processed by one thread only (e.g. I don't want row 1 to be processed by thread 1 and thread 3).
I can also use a DataReader if that helps, but I need to dow some locking logic I would have thought. Can anybody please help as I've no experience of doing this before?
Thank you
|
|
|
|
|
Pass each thread a row to process, or a list of rows to process. Lock won't help you much here since it suspends the thread until the lock is released. You would need to check if a thread is (or has) processed that row, which is a different logic altogether. If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
Ok, thanks. So how do check if it has processed or is processing a row which has been used/is being used?
Thanks
|
|
|
|
|
Yo will have to do that yourself - either by handing the thread only the row(s) you want it to process (my preferred option) or by keeping a list of all rows that have been processed and checking it in your thread. If you go for the second option, you will need to lock the list before your threads access it! If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
Thanks, yes it would probably be best to just set each numbered thread to use certain segments of the data. For example, I have set the first thread to process rows 0 to 9999 of the DataSet, etc.
Thanks
|
|
|
|
|
Good day!
I creating disc burning app (like nero).
I'm using udf 2.5 FileSystem.
After burning cd/dvd media contents not refreshed , in media(disc) shows old contents. But, if i try from Windows OS cd/dvd media refreshing after burning.
How i can refresh media(disc) contents after burning?
Please help me.
Thanks, Nematjon.We are haven't bug,just temporarily undecided problems.
|
|
|
|
|
See if you can find something here[^].Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Thanks for reply Abhinav.
I see this article , but i can't find what do need me!
Maybe windows have something (message , function ,...)?
Anyone know how to do it ?
Thanks.We are haven't bug,just temporarily undecided problems.
|
|
|
|
|
I derived a new class from DataGridViewTextBoxCell in my application and overrided the function GetFormattedValue
In GetFormattedValue, I do some data binding (for example I read a ID from the database on the web and I show the corresponding name of that item from my local information which are pre-read in a datatable).
However, some databinding need to query from the web. It slowed down the application so every time when I need to do the bindings related to the web, I open a new thread to do the query, and show the original value(e.g. the item's ID) at the moment first.
The problem now is I don't know how to invoke the GetFormattedValue function when the query is finished so that it would show the desired value (e.g. the item's name).
Anyone could help? Thanks a lot=]
|
|
|
|
|
I have found the solution, in case any other guy meet with the same problem, I leave it here.
For the cell's datagridview, call Refresh() would make it.
|
|
|
|
|
Hi!
I'm building a MailMessage object containing html body with embedded images. How can I now display the content of the message with its embedded pictures in an UI control like WebBrowser?
Thank you!
|
|
|
|
|
Extract the HTML to a file in a temp folder. Then extract the images to that same folder. You may have to adjust the HTML so it points to those images correctly. Then point the WebBrowser to the HTML file you created in the temp folder.
|
|
|
|
|
There are free controls available to show html content. use that
|
|
|
|
|
I understand I can do the following to remove text from controls in this case the textbox
private void add_Button_Click(object sender, EventArgs e)
{
foreach (Control control in recordinput_groupbox.Controls)
{
if(control.GetType() == typeof(TextBox))
{
control.Text = string.Empty;
}
}
but what if they are bound? Notice the control.Databindings.clear();
that works but the problem is after I get done updating records or adding/ I want to reload the data so the user can select another item if they wish via the bindingnavigator to update. when the databinding is cleared then obviously it is no longer bound.
Is it wise to simply make a function to bind the controls back after the update or is there a easier better way of handling this? I tried to search on here and good for it but It never really addressed the per say correct way.
thanks for your time.
|
|
|
|
|
I assume you are using WPF (I could be wrong)...
I'm not quite sure what you are trying to accomplish. It sounds like you want to clear a TextBox (for example) then add the binding back to it later. Perhaps you could just change the value the TextBox.Text property is bound to (i.e., set it to an empty string)?
|
|
|
|
|
Yes it is a winform. Well, what the issue is is i can do empty.string and all is fine. However,
when the user goes to input data and hits tab to go to the next field it automatically populates with the old bound data. I don't have autocomplete enabled unless it's somehow by default.
lets say the original data for AuthorLast_Textbox is Smith
i hit add and it wipes it to the empty string that is fine. but when if i'm on Authorfirst_textbox and type in Sam and then hit tab I will automatically get smith populated in the authorlast_textbox.
I assume that is because it is databound.
thanks for your help by the way.
|
|
|
|
|
Hi All,
does the WIN32_BIOS uniquely identifies a windows box globally, even this windows box does not connect to any network.
I want to propose a licencing schema that minimise the pirating of my software.
|
|
|
|
|
If it was that simple, then everyone would do it!
There are a number of unique numbers you can get, for example Processor, NIC, HDD, and so forth, so you can generate a code sequence which will ID a PC pretty well, but you have to tie that back (normally via a website) to your system.
It is going to depend on a range of factors: How much you want to protect your software against the irritation to genuine users. What kind of users are you talking about - mass market will have hackers playing with it if it is any good, more specialised users may need less protection
For example, if I buy software, then replace my network card and have to re-install then I generally become annoyed and tend not to buy that software again. Some users don't like to connect to internet every time they try to use software - it's a privacy or a dial up issue.
You are not alone in this: Google for "unique pc identifier" and you will get millions of hits!
Sorry not to be much help, but it isn't a case of "do this and it will be ok" - it's more "how much effort will you have to put in to achieve the result you need"If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
Thanks alot for your posting and actually it was quite helpful, I think i might use several hardware ids to protect my software, such as i could validate processor serial number, motherboard Id, MAC address, hard disk serial number etc. if any of these Ids can be validated, then we would say the software is geniune user. If a uses completely upgrade his/her system, then the user has to let us know.
|
|
|
|
|
|
You should probably use WMI to gather a system-specific info string, and encrypt it, and transfer the encrypted info to a database that's not on the user's machine. When the program runs, it should perform this same process, and if the encrypted string it comes up with doesn't match what's in the database, don't let the program run.
A few considerations:
0) if there is no internet connection, the program should run as it normally would if it was validated.
1) If it can't find the validation server, the program should run as it normally would if it was validated.
2) In the event that the app goes EOL or you no longer want to require remote validation, provide a method for the program to run WITHOUT checking the validation server. My suggestoion is an entry in the app.config file that tells the app not to bother checking..45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
this is indeed a good answer thanks
|
|
|
|