|
Hi,
I can't explain the doubles, every time you add or remove an item to the selection,
the event will fire but since you always clear the ArrayList that should not cause
wrong results.
However I do suggest you use SelectedItems instead of SelectedIndices, it will yield simpler code,
skipping all the index stuff.
|
|
|
|
|
natsuyaki,
Add some Trace'ing so that you know how many items are selected, and then how many items are added to the arraylist and what those items are.
Also, if you're using .NET 2.0 upwards, i'd change the arraylist to a generic list, just makes life easier.
Regards,
Gareth.
|
|
|
|
|
Where do you create a new arraylist ?
Is there a chance that you are creating a new copy each time hence having more than one instance of al ?
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|
|
How do you determine what the ArrayList contains?
Are you stuck with framework 1.1? Otherwise you should use a List<string> instead of an ArrayList.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thx everyone...
al is all right.The problem is: the main thread print this list, and then another thread tried again....
|
|
|
|
|
Hey guys
i need to programaticly stop a sql server and then start it again
the reson for this is that i have to delete a database even if its in use, then create the database again...
or is there some other programatical way of "kicking" the connections to that database?
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
You can try ClearAllPools() or ClearPool() to clear the ADO.NET connection pool. To restart SQL Server, you need to restart the service. Check this[^] to get an idea about starting/stopping services through code.
|
|
|
|
|
thanx
ill have a look at it
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
I'd try this[^] and if that doesn't work for you then there's this[^]. Forgive me, both examples are in VB but converting them to C# shouldn't be too hard
|
|
|
|
|
Thanx man, it works like a charm
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
i am sooo sorry i never knew how things are done here,this is my first time of askin a question,i am not in the habi....I AM SO SORRY. i am actually workin on a desktop application..
and nobody will understand my code but i want to implement it in this area
its over 5000 lines of code, i thot nobody will be interested in that sh*t..
I AM VERY SORRY IF I HAVE OFFENDED ANYONE WITH MY APPROACH..
I WILL BE VERY GLAD TO REMAIN HERE...
if (readval1.Read())
{
//assign these values into current sem sum variables
int TUT3, TUP3, COUT3;
decimal WS3, GPA3;
TUT3 = System.Convert.ToInt16(readval1.GetValue(3).ToString());
TUP3 = System.Convert.ToInt16(readval1.GetValue(4).ToString());
WS3 = System.Convert.ToDecimal(readval1.GetValue(5).ToString());
GPA3 = System.Convert.ToDecimal(readval1.GetValue(6).ToString());
COUT3 = System.Convert.ToInt16(readval1.GetValue(7).ToString());
MessageBox.Show("TUT = " + TUT3.ToString() + "TUP = " + TUP3.ToString() + "WS = " + WS3.ToString() + "GPA = " + GPA3.ToString() + "Outstanding = " + COUT3.ToString());
//add the values of previous sem to current semester
decimal CUT3, CUP3, AOUT3;
decimal CWS3, CGPA3;
CUT3 = (TUT3 + PTUT2);
CUP3 = (TUP3 + PTUP2);
CWS3 = (WS3 + PCWS2);
CGPA3 = Math.Round((CWS3 / CUT3), 2);
AOUT3 = System.Convert.ToInt32((CUT3 - CUP3));
MessageBox.Show("CUT =" + CUT3 + " CUP = " + CUP3 + " CWS =" + CWS3 + " CGPA =" + CGPA3 + " OUT =" + AOUT3);
//update All Semester Summary
string updalltab = "UPDATE AllSemesterSummary SET Levels = '200', Semester = '2', CumulativeUnitTaken = '" + CUT3 + "', CumulativeUnitPassed = '" + CUP3 + "', CumulativeWeightedScore = '" + CWS3 + "', CumulativeGradePointAverage = '" + CGPA3 + "', OutstandingUnits = '" + AOUT3 + "' WHERE MatricNumber = '" + matnumber + "' ";
Oluwayomi Ige
MCP MCAD.
|
|
|
|
|
Please ignore the duplicate post
Best Regards
-----------------
Abhijit Jana
"Success is Journey it's not a destination"
|
|
|
|
|
This is about as bad as code gets, plus you have not actually asked a question - you've just posted your crap repeatidly.
Stick to 419's!
|
|
|
|
|
Jamie is correct. This is some really nasty code and you haven't asked a question about it.
Oluwayomi wrote: and nobody will understand my code
So, you're saying that you're writing code like this in an effort to build "job security" for yourself?? Thank God, 'cause I wouldn't want to be the poor bastard coming in behind you to support this code.
|
|
|
|
|
i am sooo sorry i never knew how things are done here,this is my first time of askin a question,i am not in the habi....I AM SO SORRY. i am actually workin on a desktop application..
and nobody will understand my code but i want to implement it in this area
its over 5000 lines of code, i thot nobody will be interested in that sh*t..
I AM VERY SORRY IF I HAVE OFFENDED ANYONE WITH MY APPROACH..
I WILL BE VERY GLAD TO REMAIN HERE...
if (readval1.Read())
{
//assign these values into current sem sum variables
int TUT3, TUP3, COUT3;
decimal WS3, GPA3;
TUT3 = System.Convert.ToInt16(readval1.GetValue(3).ToString());
TUP3 = System.Convert.ToInt16(readval1.GetValue(4).ToString());
WS3 = System.Convert.ToDecimal(readval1.GetValue(5).ToString());
GPA3 = System.Convert.ToDecimal(readval1.GetValue(6).ToString());
COUT3 = System.Convert.ToInt16(readval1.GetValue(7).ToString());
MessageBox.Show("TUT = " + TUT3.ToString() + "TUP = " + TUP3.ToString() + "WS = " + WS3.ToString() + "GPA = " + GPA3.ToString() + "Outstanding = " + COUT3.ToString());
//add the values of previous sem to current semester
decimal CUT3, CUP3, AOUT3;
decimal CWS3, CGPA3;
CUT3 = (TUT3 + PTUT2);
CUP3 = (TUP3 + PTUP2);
CWS3 = (WS3 + PCWS2);
CGPA3 = Math.Round((CWS3 / CUT3), 2);
AOUT3 = System.Convert.ToInt32((CUT3 - CUP3));
MessageBox.Show("CUT =" + CUT3 + " CUP = " + CUP3 + " CWS =" + CWS3 + " CGPA =" + CGPA3 + " OUT =" + AOUT3);
//update All Semester Summary
string updalltab = "UPDATE AllSemesterSummary SET Levels = '200', Semester = '2', CumulativeUnitTaken = '" + CUT3 + "', CumulativeUnitPassed = '" + CUP3 + "', CumulativeWeightedScore = '" + CWS3 + "', CumulativeGradePointAverage = '" + CGPA3 + "', OutstandingUnits = '" + AOUT3 + "' WHERE MatricNumber = '" + matnumber + "' ";
Oluwayomi Ige
MCP MCAD.
|
|
|
|
|
Oluwayomi wrote: I AM VERY SORRY IF I HAVE OFFENDED ANYONE WITH MY APPROACH..
I WILL BE VERY GLAD TO REMAIN HERE...
You didn't, and I apologise if you thought it was personal. There are some rules when posting in forums, and things can get a bit heated (read sarcastic) if these rules aren't adhered to. The first rule is that we don't do work for others. We'll help if they are stuck on a particular problem, but we won't write solutions. Secondly, we need decent descriptions of the problem - only then can we help. Third, we need to know that you've tried to solve the problem for yourself.
Tick all those boxes and you'll find your time on the boards a much more pleasant one.
|
|
|
|
|
Oluwayomi wrote: (To whom it may concern)SEE THIS ITS IMPORTANT
Try to put some useful information in the subject line, so that it says anything about the question. That subject line contains no useful information at all.
Oluwayomi wrote: I AM VERY SORRY IF I HAVE OFFENDED ANYONE WITH MY APPROACH..
I WILL BE VERY GLAD TO REMAIN HERE...
You are very welcome to stay here, if you just STOP SCREAMING!
Oluwayomi wrote: nobody will understand my code
Perhaps if you said anything at all about what the code is supposed to do...?
Oluwayomi wrote: int TUT3, TUP3, COUT3;
Don't be afraid to use variable names that are somewhat longer. If you can see from the variable name what the variable is supposed to be used for, it's easier to understand the code, and easier to find errors.
Oluwayomi wrote: UT3 = System.Convert.ToInt16(readval1.GetValue(3).ToString());
An int is not an Int16 , it's an Int32 .
Why are you getting the value as a string, then convert it to a number? Do you store everything as text in the database?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
Best Regards
-----------------
Abhijit Jana
"Success is Journey it's not a destination"
|
|
|
|
|
Thanks Pete O'Hanlon,ve to get back to work...
Oluwayomi Ige
MCP MCAD.
|
|
|
|
|
My cats breath smells like cat food!
|
|
|
|
|
Men...because im certified doesnt mean i knw the whole world...it might interest you to know that i have written my code..just needed ideas...WHY IS THIS A COMMUNITY?...ARE WE SUPPOSE TO HELP OR LAUGH AT? THOT I COULD COUNT ON PEOPLE HERE, I HAVE NEVER ASKED QUESTION HERE BEFORE, MY FIRST TIME IS A TOTAL NIGHTMARE....I AM OUT
Oluwayomi Ige
MCP MCAD.
|
|
|
|
|
Seriously though - you do know that we aren't here to write your code for you don't you? You didn't demonstrate that you had written a single line of code, and come on - this wasn't exactly a tough problem now was it? Hardly one that would tax a rocket scientist like yourself.
|
|
|
|
|
Fact is you posted not a question, but a vague demand. No please, no thank you, and the "problem" was poorly defined. Although anyway you look at the "problem", seriously, you don't know how to "triple" something? Be that performing elementary maths or repeating something three times.
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
Oluwayomi wrote: i have written my code..just needed ideas..
So why not post your code and ask if anyone has a better suggestion? Then people would take your question seriously. I know myself I have sometimes written a piece of code and thought 'there must be a better way' but have had a mental block about how to do it better.
Bob
Ashfield Consultants Ltd
|
|
|
|