I have six textbox controls on my webform that allows the user to enter any
numbers from 1 to 25 in any order. However, I would like to sort those
numbers from least to greatest before sending them to the database. How can
accomplish this task? Thanks! 11 1821
Easiest way is to use the ArrayList Sort method.
//sorry if you were looking for this in vb
ArrayList list = new ArrayList();
list.Add( Int32.Parse( txt1.Text ) );
list.Add( Int32.Parse( txt2.Text ) );
list.Add( Int32.Parse( txt3.Text ) );
list.Add( Int32.Parse( txt4.Text ) );
list.Add( Int32.Parse( txt5.Text ) );
list.Add( Int32.Parse( txt6.Text ) );
//this will place them in order inside the array.
list.Sort();
//this will pull them back out in order now.
foreach( int i in list )
{
}
HTH,
bill
"Leon" <vn*****@msn.com> wrote in message
news:eC**************@TK2MSFTNGP09.phx.gbl... I have six textbox controls on my webform that allows the user to enter
any numbers from 1 to 25 in any order. However, I would like to sort those numbers from least to greatest before sending them to the database. How
can accomplish this task? Thanks!
Thanks for your response! But...
but then how work apply the sorted numbers to my database stored procedure
parameters?
"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl... Easiest way is to use the ArrayList Sort method.
//sorry if you were looking for this in vb ArrayList list = new ArrayList();
list.Add( Int32.Parse( txt1.Text ) ); list.Add( Int32.Parse( txt2.Text ) ); list.Add( Int32.Parse( txt3.Text ) ); list.Add( Int32.Parse( txt4.Text ) ); list.Add( Int32.Parse( txt5.Text ) ); list.Add( Int32.Parse( txt6.Text ) );
//this will place them in order inside the array. list.Sort();
//this will pull them back out in order now. foreach( int i in list ) {
}
HTH,
bill
"Leon" <vn*****@msn.com> wrote in message news:eC**************@TK2MSFTNGP09.phx.gbl... I have six textbox controls on my webform that allows the user to enter any numbers from 1 to 25 in any order. However, I would like to sort those numbers from least to greatest before sending them to the database. How can accomplish this task? Thanks!
> but then how work apply the sorted numbers to my database stored procedure parameters?
After looking over your stored procedure, and its parameters, and the code
that populates them from your current code, I can say that you never posted
your stored procedure, its parameters, or any of your code.
One at a time? Very carefully? Post more information?
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
"Leon" <vn*****@msn.com> wrote in message
news:OH**************@TK2MSFTNGP14.phx.gbl... Thanks for your response! But... but then how work apply the sorted numbers to my database stored procedure parameters?
"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message news:%2***************@TK2MSFTNGP14.phx.gbl... Easiest way is to use the ArrayList Sort method.
//sorry if you were looking for this in vb ArrayList list = new ArrayList();
list.Add( Int32.Parse( txt1.Text ) ); list.Add( Int32.Parse( txt2.Text ) ); list.Add( Int32.Parse( txt3.Text ) ); list.Add( Int32.Parse( txt4.Text ) ); list.Add( Int32.Parse( txt5.Text ) ); list.Add( Int32.Parse( txt6.Text ) );
//this will place them in order inside the array. list.Sort();
//this will pull them back out in order now. foreach( int i in list ) {
}
HTH,
bill
"Leon" <vn*****@msn.com> wrote in message news:eC**************@TK2MSFTNGP09.phx.gbl... I have six textbox controls on my webform that allows the user to enter any numbers from 1 to 25 in any order. However, I would like to sort those numbers from least to greatest before sending them to the database. How can accomplish this task? Thanks!
Thanks for your response.. But
I don't understand what you mean by..
"After looking over your stored procedure, and its parameters, and the code
that populates them from your current code, I can say that you never posted
your stored procedure, its parameters, or any of your code."
This is my original question..
I have six textbox controls on my webform that allows the user to enter any
numbers from 1 to 25 in any order. However, I would like to sort those
numbers from least to greatest before sending them to the database. How can
accomplish this task? Thanks again!
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:OM**************@TK2MSFTNGP11.phx.gbl... but then how work apply the sorted numbers to my database stored procedure parameters?
After looking over your stored procedure, and its parameters, and the code that populates them from your current code, I can say that you never posted your stored procedure, its parameters, or any of your code.
One at a time? Very carefully? Post more information?
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Neither a follower nor a lender be.
"Leon" <vn*****@msn.com> wrote in message news:OH**************@TK2MSFTNGP14.phx.gbl... Thanks for your response! But... but then how work apply the sorted numbers to my database stored procedure parameters?
"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message news:%2***************@TK2MSFTNGP14.phx.gbl... > Easiest way is to use the ArrayList Sort method. > > //sorry if you were looking for this in vb > ArrayList list = new ArrayList(); > > list.Add( Int32.Parse( txt1.Text ) ); > list.Add( Int32.Parse( txt2.Text ) ); > list.Add( Int32.Parse( txt3.Text ) ); > list.Add( Int32.Parse( txt4.Text ) ); > list.Add( Int32.Parse( txt5.Text ) ); > list.Add( Int32.Parse( txt6.Text ) ); > > //this will place them in order inside the array. > list.Sort(); > > //this will pull them back out in order now. > foreach( int i in list ) > { > > } > > HTH, > > bill > > > "Leon" <vn*****@msn.com> wrote in message > news:eC**************@TK2MSFTNGP09.phx.gbl... >> I have six textbox controls on my webform that allows the user to >> enter > any >> numbers from 1 to 25 in any order. However, I would like to sort those >> numbers from least to greatest before sending them to the database. >> How > can >> accomplish this task? Thanks! >> >> > >
what do u mean by "but then how work apply the sorted numbers to my database
stored procedure
parameters? " ???
If you can give details about ur stored proc and its parameters with your
source code, somebody might give a solution.
Vinay
"Leon" wrote: Thanks for your response! But... but then how work apply the sorted numbers to my database stored procedure parameters?
"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message news:%2***************@TK2MSFTNGP14.phx.gbl... Easiest way is to use the ArrayList Sort method.
//sorry if you were looking for this in vb ArrayList list = new ArrayList();
list.Add( Int32.Parse( txt1.Text ) ); list.Add( Int32.Parse( txt2.Text ) ); list.Add( Int32.Parse( txt3.Text ) ); list.Add( Int32.Parse( txt4.Text ) ); list.Add( Int32.Parse( txt5.Text ) ); list.Add( Int32.Parse( txt6.Text ) );
//this will place them in order inside the array. list.Sort();
//this will pull them back out in order now. foreach( int i in list ) {
}
HTH,
bill
"Leon" <vn*****@msn.com> wrote in message news:eC**************@TK2MSFTNGP09.phx.gbl... I have six textbox controls on my webform that allows the user to enter any numbers from 1 to 25 in any order. However, I would like to sort those numbers from least to greatest before sending them to the database. How can accomplish this task? Thanks!
Here is the stored procedure, but I have not wrote any source code because I
trying to figure-out the best way to go about accomplishing my mission which
is I have six textbox controls on my webform that allows the user to enter
any numbers from 1 to 25 in any order. However, I would like to sort those
numbers from least to greatest before sending them to the database. Thanks!
CREATE PROCEDURE AddNumbers
(
@Num1 tinyint,
@Num2 tinyint,
@Num3 tinyint,
@Num4 tinyint,
@Num5 tinyint,
@Num6 tinyint
)
AS
INSERT Number (
Num1,
Num2,
Num3,
Num4,
Num5,
Num6
) VALUES (
@Num1,
@Num2,
@Num3,
@Num4,
@Num5,
@Num6
)
GO
"vinay" <vi***@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com... what do u mean by "but then how work apply the sorted numbers to my database stored procedure parameters? " ???
If you can give details about ur stored proc and its parameters with your source code, somebody might give a solution.
Vinay
"Leon" wrote:
Thanks for your response! But... but then how work apply the sorted numbers to my database stored procedure parameters?
"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message news:%2***************@TK2MSFTNGP14.phx.gbl... > Easiest way is to use the ArrayList Sort method. > > //sorry if you were looking for this in vb > ArrayList list = new ArrayList(); > > list.Add( Int32.Parse( txt1.Text ) ); > list.Add( Int32.Parse( txt2.Text ) ); > list.Add( Int32.Parse( txt3.Text ) ); > list.Add( Int32.Parse( txt4.Text ) ); > list.Add( Int32.Parse( txt5.Text ) ); > list.Add( Int32.Parse( txt6.Text ) ); > > //this will place them in order inside the array. > list.Sort(); > > //this will pull them back out in order now. > foreach( int i in list ) > { > > } > > HTH, > > bill > > > "Leon" <vn*****@msn.com> wrote in message > news:eC**************@TK2MSFTNGP09.phx.gbl... >> I have six textbox controls on my webform that allows the user to >> enter > any >> numbers from 1 to 25 in any order. However, I would like to sort those >> numbers from least to greatest before sending them to the database. >> How > can >> accomplish this task? Thanks! >> >> > >
You would have to create a parameter to hold each of your values in the new
array.
So..
Dim cmd as new Sqlcommand("what ever")
cmd.parameters.add("@value1" , list(0))
cmd.parameters.add("@value2" , list(1))
.......
cmd.parameters.add("@value5" , list(4))
cmd.parameters.add("@value6" , list(5))
list is your sorted arrayList.
Is this what you mean?
"Leon" wrote: Thanks for your response! But... but then how work apply the sorted numbers to my database stored procedure parameters?
"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message news:%2***************@TK2MSFTNGP14.phx.gbl... Easiest way is to use the ArrayList Sort method.
//sorry if you were looking for this in vb ArrayList list = new ArrayList();
list.Add( Int32.Parse( txt1.Text ) ); list.Add( Int32.Parse( txt2.Text ) ); list.Add( Int32.Parse( txt3.Text ) ); list.Add( Int32.Parse( txt4.Text ) ); list.Add( Int32.Parse( txt5.Text ) ); list.Add( Int32.Parse( txt6.Text ) );
//this will place them in order inside the array. list.Sort();
//this will pull them back out in order now. foreach( int i in list ) {
}
HTH,
bill
"Leon" <vn*****@msn.com> wrote in message news:eC**************@TK2MSFTNGP09.phx.gbl... I have six textbox controls on my webform that allows the user to enter any numbers from 1 to 25 in any order. However, I would like to sort those numbers from least to greatest before sending them to the database. How can accomplish this task? Thanks!
We need to see the code that you have now that is sending to database. I
will try to guess what you want.
ArrayList list = new ArrayList();
//add the numbers to the list
list.Add( Int32.Parse( txt1.Text ) );
list.Add( Int32.Parse( txt2.Text ) );
list.Add( Int32.Parse( txt3.Text ) );
list.Add( Int32.Parse( txt4.Text ) );
list.Add( Int32.Parse( txt5.Text ) );
list.Add( Int32.Parse( txt6.Text ) );
//this will sort the numbers
list.Sort();
SendToDatabase( list[0] );
SendToDatabase( list[1] );
SendToDatabase( list[2] );
SendToDatabase( list[3] );
SendToDatabase( list[4] );
SendToDatabase( list[5] );
This will send the numbers in order to the database. This is assuming you
have a method defined called SendToDatabase(). And inside this method you
make your database connection, create your command text, etc. If you need
help on inserting something to a database then ask that question, but add
things like....Sql Server, Access, using Stored Procedures, Xml DataSet,
etc.
We will all need more information if this is not what you are looking for.
Your original question was how to sort them BEFORE sending to the database.
The list.Sort() method will sort them.
If you have another question, please ask it, but repeating your first
question will just get a similiar answer.
bill
"Leon" <vn*****@msn.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Thanks for your response.. But I don't understand what you mean by..
"After looking over your stored procedure, and its parameters, and the
code that populates them from your current code, I can say that you never
posted your stored procedure, its parameters, or any of your code."
This is my original question.. I have six textbox controls on my webform that allows the user to enter
any numbers from 1 to 25 in any order. However, I would like to sort those numbers from least to greatest before sending them to the database. How
can accomplish this task? Thanks again!
"Kevin Spencer" <ks******@takempis.com> wrote in message news:OM**************@TK2MSFTNGP11.phx.gbl... but then how work apply the sorted numbers to my database stored procedure parameters?
After looking over your stored procedure, and its parameters, and the
code that populates them from your current code, I can say that you never posted your stored procedure, its parameters, or any of your code.
One at a time? Very carefully? Post more information?
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Neither a follower nor a lender be.
"Leon" <vn*****@msn.com> wrote in message news:OH**************@TK2MSFTNGP14.phx.gbl... Thanks for your response! But... but then how work apply the sorted numbers to my database stored procedure parameters?
"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message news:%2***************@TK2MSFTNGP14.phx.gbl... > Easiest way is to use the ArrayList Sort method. > > //sorry if you were looking for this in vb > ArrayList list = new ArrayList(); > > list.Add( Int32.Parse( txt1.Text ) ); > list.Add( Int32.Parse( txt2.Text ) ); > list.Add( Int32.Parse( txt3.Text ) ); > list.Add( Int32.Parse( txt4.Text ) ); > list.Add( Int32.Parse( txt5.Text ) ); > list.Add( Int32.Parse( txt6.Text ) ); > > //this will place them in order inside the array. > list.Sort(); > > //this will pull them back out in order now. > foreach( int i in list ) > { > > } > > HTH, > > bill > > > "Leon" <vn*****@msn.com> wrote in message > news:eC**************@TK2MSFTNGP09.phx.gbl... >> I have six textbox controls on my webform that allows the user to >> enter > any >> numbers from 1 to 25 in any order. However, I would like to sort
those >> numbers from least to greatest before sending them to the database. >> How > can >> accomplish this task? Thanks! >> >> > >
thanks!
"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message
news:eL**************@TK2MSFTNGP12.phx.gbl... We need to see the code that you have now that is sending to database. I will try to guess what you want.
ArrayList list = new ArrayList();
//add the numbers to the list list.Add( Int32.Parse( txt1.Text ) ); list.Add( Int32.Parse( txt2.Text ) ); list.Add( Int32.Parse( txt3.Text ) ); list.Add( Int32.Parse( txt4.Text ) ); list.Add( Int32.Parse( txt5.Text ) ); list.Add( Int32.Parse( txt6.Text ) );
//this will sort the numbers list.Sort();
SendToDatabase( list[0] ); SendToDatabase( list[1] ); SendToDatabase( list[2] ); SendToDatabase( list[3] ); SendToDatabase( list[4] ); SendToDatabase( list[5] );
This will send the numbers in order to the database. This is assuming you have a method defined called SendToDatabase(). And inside this method you make your database connection, create your command text, etc. If you need help on inserting something to a database then ask that question, but add things like....Sql Server, Access, using Stored Procedures, Xml DataSet, etc.
We will all need more information if this is not what you are looking for. Your original question was how to sort them BEFORE sending to the database. The list.Sort() method will sort them.
If you have another question, please ask it, but repeating your first question will just get a similiar answer.
bill "Leon" <vn*****@msn.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl... Thanks for your response.. But I don't understand what you mean by..
"After looking over your stored procedure, and its parameters, and the code that populates them from your current code, I can say that you never posted your stored procedure, its parameters, or any of your code."
This is my original question.. I have six textbox controls on my webform that allows the user to enter any numbers from 1 to 25 in any order. However, I would like to sort those numbers from least to greatest before sending them to the database. How can accomplish this task? Thanks again!
"Kevin Spencer" <ks******@takempis.com> wrote in message news:OM**************@TK2MSFTNGP11.phx.gbl... >> but then how work apply the sorted numbers to my database stored >> procedure >> parameters? > > After looking over your stored procedure, and its parameters, and the code > that populates them from your current code, I can say that you never > posted > your stored procedure, its parameters, or any of your code. > > One at a time? Very carefully? Post more information? > > -- > HTH, > Kevin Spencer > .Net Developer > Microsoft MVP > Neither a follower > nor a lender be. > > "Leon" <vn*****@msn.com> wrote in message > news:OH**************@TK2MSFTNGP14.phx.gbl... >> Thanks for your response! But... >> but then how work apply the sorted numbers to my database stored >> procedure >> parameters? >> >> "William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in >> message >> news:%2***************@TK2MSFTNGP14.phx.gbl... >> > Easiest way is to use the ArrayList Sort method. >> > >> > //sorry if you were looking for this in vb >> > ArrayList list = new ArrayList(); >> > >> > list.Add( Int32.Parse( txt1.Text ) ); >> > list.Add( Int32.Parse( txt2.Text ) ); >> > list.Add( Int32.Parse( txt3.Text ) ); >> > list.Add( Int32.Parse( txt4.Text ) ); >> > list.Add( Int32.Parse( txt5.Text ) ); >> > list.Add( Int32.Parse( txt6.Text ) ); >> > >> > //this will place them in order inside the array. >> > list.Sort(); >> > >> > //this will pull them back out in order now. >> > foreach( int i in list ) >> > { >> > >> > } >> > >> > HTH, >> > >> > bill >> > >> > >> > "Leon" <vn*****@msn.com> wrote in message >> > news:eC**************@TK2MSFTNGP09.phx.gbl... >> >> I have six textbox controls on my webform that allows the user to >> >> enter >> > any >> >> numbers from 1 to 25 in any order. However, I would like to sort those >> >> numbers from least to greatest before sending them to the database. >> >> How >> > can >> >> accomplish this task? Thanks! >> >> >> >> >> > >> > >> >> > >
yes! thanks.
"Tampa .NET Koder" <Ta***********@discussions.microsoft.com> wrote in
message news:31**********************************@microsof t.com... You would have to create a parameter to hold each of your values in the new array. So.. Dim cmd as new Sqlcommand("what ever")
cmd.parameters.add("@value1" , list(0)) cmd.parameters.add("@value2" , list(1)) ...... cmd.parameters.add("@value5" , list(4)) cmd.parameters.add("@value6" , list(5))
list is your sorted arrayList.
Is this what you mean?
"Leon" wrote:
Thanks for your response! But... but then how work apply the sorted numbers to my database stored procedure parameters?
"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message news:%2***************@TK2MSFTNGP14.phx.gbl... > Easiest way is to use the ArrayList Sort method. > > //sorry if you were looking for this in vb > ArrayList list = new ArrayList(); > > list.Add( Int32.Parse( txt1.Text ) ); > list.Add( Int32.Parse( txt2.Text ) ); > list.Add( Int32.Parse( txt3.Text ) ); > list.Add( Int32.Parse( txt4.Text ) ); > list.Add( Int32.Parse( txt5.Text ) ); > list.Add( Int32.Parse( txt6.Text ) ); > > //this will place them in order inside the array. > list.Sort(); > > //this will pull them back out in order now. > foreach( int i in list ) > { > > } > > HTH, > > bill > > > "Leon" <vn*****@msn.com> wrote in message > news:eC**************@TK2MSFTNGP09.phx.gbl... >> I have six textbox controls on my webform that allows the user to >> enter > any >> numbers from 1 to 25 in any order. However, I would like to sort those >> numbers from least to greatest before sending them to the database. >> How > can >> accomplish this task? Thanks! >> >> > >
Hi Leon,
I was responding to your response, which is quoted directly under mine in
this message. However, I can see that you asked this question in 2 separte
threads, and that you did post the Stored Procedure code after I had posted
my response, and also got the correct answer, which is, to add the
parameters in the order in which they appear after sorting.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
"Leon" <vn*****@msn.com> wrote in message
news:#z**************@TK2MSFTNGP12.phx.gbl... Thanks for your response.. But I don't understand what you mean by..
"After looking over your stored procedure, and its parameters, and the
code that populates them from your current code, I can say that you never
posted your stored procedure, its parameters, or any of your code."
This is my original question.. I have six textbox controls on my webform that allows the user to enter
any numbers from 1 to 25 in any order. However, I would like to sort those numbers from least to greatest before sending them to the database. How
can accomplish this task? Thanks again!
"Kevin Spencer" <ks******@takempis.com> wrote in message news:OM**************@TK2MSFTNGP11.phx.gbl... but then how work apply the sorted numbers to my database stored procedure parameters?
After looking over your stored procedure, and its parameters, and the
code that populates them from your current code, I can say that you never posted your stored procedure, its parameters, or any of your code.
One at a time? Very carefully? Post more information?
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Neither a follower nor a lender be.
"Leon" <vn*****@msn.com> wrote in message news:OH**************@TK2MSFTNGP14.phx.gbl... Thanks for your response! But... but then how work apply the sorted numbers to my database stored procedure parameters?
"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message news:%2***************@TK2MSFTNGP14.phx.gbl... > Easiest way is to use the ArrayList Sort method. > > //sorry if you were looking for this in vb > ArrayList list = new ArrayList(); > > list.Add( Int32.Parse( txt1.Text ) ); > list.Add( Int32.Parse( txt2.Text ) ); > list.Add( Int32.Parse( txt3.Text ) ); > list.Add( Int32.Parse( txt4.Text ) ); > list.Add( Int32.Parse( txt5.Text ) ); > list.Add( Int32.Parse( txt6.Text ) ); > > //this will place them in order inside the array. > list.Sort(); > > //this will pull them back out in order now. > foreach( int i in list ) > { > > } > > HTH, > > bill > > > "Leon" <vn*****@msn.com> wrote in message > news:eC**************@TK2MSFTNGP09.phx.gbl... >> I have six textbox controls on my webform that allows the user to >> enter > any >> numbers from 1 to 25 in any order. However, I would like to sort
those >> numbers from least to greatest before sending them to the database. >> How > can >> accomplish this task? Thanks! >> >> > >
This discussion thread is closed Replies have been disabled for this discussion. Similar topics
7 posts
views
Thread by Christopher Jeris |
last post: by
|
15 posts
views
Thread by David |
last post: by
|
1 post
views
Thread by strotee |
last post: by
|
19 posts
views
Thread by David |
last post: by
|
21 posts
views
Thread by yeti349 |
last post: by
|
4 posts
views
Thread by Tony WONG |
last post: by
|
7 posts
views
Thread by ^cypis^ vel. SQ9JTI |
last post: by
|
75 posts
views
Thread by At_sea_with_C |
last post: by
| | | | | | | | | | | |