|
Hi,
The sleep thread is to avoid that my pc is going to hang. There are over 2000 rows to read into the list box.
Thanks for pointing that out to me. I didn't know it moves 2 positions within the file.
|
|
|
|
|
Yustme wrote: The sleep thread is to avoid that my pc is going to hang. There are over 2000 rows to read into the list box.
That makes no sense what so ever. If you put the thread to sleep for 10 milliseconds 2000 times you are waiting 200 seconds (just over 3 minutes) to load in all the data.
|
|
|
|
|
According to the documentation the ReadElementString method positions the reader on the node following the EndElement node; in you case on the next "test" StartElement node. Afterwards you call Read inside the while statement which advances the reader to the next node and thereby your code only recognizes every second "test" element. I'm not that used to the XmlTextReader, so you have to experiment a bit which method gives you the desired result.
By the way calling ToString on the result of ReadElementString is redundant as it already returns a string.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
Can you tell me what method you used for these kind of operations?
Thanks in advance!
|
|
|
|
|
As said I'm not used to the XmlTextReader but after a quick glance at the documentation I would say that the ReadString method sounds quite promissing.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
That did the trick.
Thanks!
|
|
|
|
|
Hi Frens,
I am trying to provide the same kind of search facility which has been given in this link...
http://office.microsoft.com/en-us/default.aspx
But I am not sure how to do this....can u pls help me out..
Thanks in advance...
Vishal
|
|
|
|
|
Which bit are you looking for? The watermark? The UI? Actually searching for something?
Your post is too vague. You need to provide more information before people can answer it.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi all,
I found a code to convert a Image to byte array and back.
the image gets converted to byte array succesfully..
but when i try to convert the bytearray back to Image it gives and error saying
"Parameter is not Valid"
The code is as below:
MemoryStream ms = new MemoryStream(br); // br is the byte array
pictureBox2.Image = Image.FromStream(ms);****Error at this line...
Can anyone tell me how to solve this or some other way to it?
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
I'd expect that means your byte array doesn't contain all the information required to build an image. A byte array of pixel values is not what is needed here.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks for quick reply
The problem is it works for some time and then the error occurs...
i have displayed a messagebox. the messagebox is displayed 4-5 times and then the error occurs.
The main purpose of the application is i am capturing images from a camera and sending it over network.
So when i receive it back and try to convert it from a byte array to an image the error occurs.
Can u suggest any better way for this?
or what should be done if the byte array doesn't contains all the information?
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
If it's not all there, there's not much you can do. If it works sometimes, then I guess perhaps sometimes the info is lost, assuming it's being created correctly in the first place.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You aren't saying how you converted it to a byte array to begin with. If the byte array only contains the bitmap's pixel data, it's not going to work. You have to save the full bitmap data, including the header information. You can do this by using Bitmap.Save(), passing in a MemoryStream that points to the byte array.
If you want to create a bitmap from raw pixel data (without a header), you must give GDI+/System.Drawing the information it needs in order to interpret the pixel data. You can create an empty bitmap of the right size and format, and copy the data into it using Bitmap.LockBits() and Buffer.Copy(), or you can create a bitmap that directly uses the byte array as its pixel storage - see my EditableBitmap class[^] for an example.
|
|
|
|
|
i have used the Save method of the image to save that to a memory stream and then used the ToArray method of the memory stream to convert the image to byte array
actually the image is captured from a cam and displayed in a picturebox,
so i cannot use the above mentioned method, coz that will lock the image, is wht i think.
is there any other way to do that?
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Hi,
Ok now this is just weird. i used this line of code everyday and worked fine and suddenly this morning just threw an error in my face
<br />
DateTime dt = Convert.ToDateTime(cpCreateDate.SelectedDate.ToString("dd/MM/yyyy"));<br />
ok the cpCreateDate control is a datetime picker and the value is for example
"09/01/2007 12:00:00 AM"
all i want to do is format it to only the date meaning removing the time to save this to a sql database.
the problem is that as soon as it converts the string back to a datetime value it keeps on adding the time back again and i get this error when trying to write the value to the database:
"The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.
The statement has been terminated."
the column in the sql database table is a smalldatetime data type and changing that to normal datetime doesnt resolve this.
please help
thanks
|
|
|
|
|
Wouldn't this be easier ?
DateTime dt = new DateTime(cpCreateDate.SelectedDate.Year, cpCreateDate.SelectedDate.Month, cpCreateDate.SelectedDate.Day) ?
A lot less expensive than string to date conversions.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
//you can use substring method like this:
cpCreateDate.SelectedDate.ToString("dd/MM/yyyy").Substring(0,10)
|
|
|
|
|
I think you are trying to strip time because you think that small date time is only date field (lots of users think that, i don't know why, i guess there is something like that in Access), but that is not true. This data field just shortens range of valid values while keeping the time. Valid dates for a SMALLDATETIME column can range from January 1, 1900 to June 6, 2079.
If I'm wrong, and that is not what error is about than you can simply strip time with:
cpCreateDate.SelectedDate.Date;
|
|
|
|
|
You can also poke your eyes out with a screwdriver, but it doesnt mean its a good idea.
hint: what happens to your code when my date format is long date ie/09 January 2007
|
|
|
|
|
Hi all,
I'm coding a sql server job monitor usnig sql-dmo and c#.
I need help on how to use JobFilter interface.
Here is a sample of my code:
JobFilter _jf = null;
_jf.Category = "SAGAII";
QueryResults _qr = _srv.JobServer.EnumJobs(_jf);
The code results in an error.
Please help!
Thanks in advance
|
|
|
|
|
Hi all,
I have a problem manipulating form contrls in user thread or our made threads.
In VS 2003 this code was running fine that is on a button click we make a new thread , pass it the function to call and start it but in VS 2005 it is making problem and giving a "CROSS THREAD OPERATION EXCEPTION". I dont knw why. Is there a way to call the threaded function and manipulate MULTIPLE form controls.
Thanks in adv
Reply soon
private void button1_Click(object sender, System.EventArgs e)
{
Thread newthrd = new Thread(new ThreadStart(Increment_ProgressBar));
newthrd.Start();
}
private void Increment_ProgressBar()
{
for(int count=0;count<101;count++)
{
progressBar1.Value = count;
Thread.Sleep(100);
}
}
Bye
|
|
|
|
|
UI controls should only be accessed from the thread they were created on cause otherwise your application may show some strange behaviour e.g. freezes. Obviously you were lucky and never encountered such problems, but it doesn't mean they will never occur. To inform developers about this possible problem the CrossThreadOperationException is thrown in Framework 2.0.
Some information and ways to get around are presented in this good CP article: What's up with BeginInvoke?[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I dont have one control to deal on... the number is about 50. so do i've to call begininvoke() for every control im using. isnt there a possible way out like in VS2003.
Bye
|
|
|
|
|
Mr.Sam wrote: so do i've to call begininvoke() for every control im using.
As said you should always use Invoke or BeginInvoke when accessing an UI control from a thread other than the one it was created on. In case you access many controls from your worker thread you could maybe encapsulate all manipulations of the UI in one method and invoke it whenever you want to update the user interface.
Mr.Sam wrote: isnt there a possible way out like in VS2003.
Take a look at Christian's answer.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
hint: it won't work with the Thread , but if ever you should use the Timer class look into the SynchronizingObject property.
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|