In my application, there are 10 threads running to accomplish an operation. For that, all those threads will fetch data from the database and fills the datatable and totally there will be 10 datatables. All the 10 threads executes the same query and fetches
the same data and same number of rows. In data fetch query, i will add x and y columns for the Order By, but there are some possibility of getting similar values in these x and y columns. Now what it does is, each thread is filling the datatable in different
order. say for example, in thread 1 it fetches the data and fill as
a b x(order by) y(order by)
1 2 0 0
2 3 1 1
3 4 1 1
4 5 1 1
5 6 1 1
6 7 1 1
But thread 2 fills like
a b x(order by) y(order by)
1 2 0 0
2 3 1 1
4 5 1 1
6 7 1 1
5 6 1 1
3 4 1 1
<div>it changes the order because the order by column's values are same. so how to avoid. i must not allowed to add the column a or b with the order by. its the requirement to add x and y columns in the order by. so is there any possibility to achieve this
functionality? </div> <div></div> <div>Thanks in advance,</div> <div>abivenkat</div>
abivenkat
Member
50 Points
97 Posts
Filling Datatable from database
Dec 22, 2012 11:09 AM|LINK
hi all,
In my application, there are 10 threads running to accomplish an operation. For that, all those threads will fetch data from the database and fills the datatable and totally there will be 10 datatables. All the 10 threads executes the same query and fetches the same data and same number of rows. In data fetch query, i will add x and y columns for the Order By, but there are some possibility of getting similar values in these x and y columns. Now what it does is, each thread is filling the datatable in different order. say for example, in thread 1 it fetches the data and fill as
a b x(order by) y(order by)
1 2 0 0
2 3 1 1
3 4 1 1
4 5 1 1
5 6 1 1
6 7 1 1
But thread 2 fills like
a b x(order by) y(order by)
1 2 0 0
2 3 1 1
4 5 1 1
6 7 1 1
5 6 1 1
3 4 1 1
<div>it changes the order because the order by column's values are same. so how to avoid. i must not allowed to add the column a or b with the order by. its the requirement to add x and y columns in the order by. so is there any possibility to achieve this functionality? </div> <div></div> <div>Thanks in advance,</div> <div>abivenkat</div>urenjoy
Star
12047 Points
1807 Posts
Re: Filling Datatable from database
Dec 22, 2012 11:24 AM|LINK
It would be better to add primary key field in order criteria to get same result each time. Have a look at following good explanations:
http://blog.sqlauthority.com/2007/09/24/sql-server-order-of-result-set-of-select-statement-on-clustered-indexed-table-when-order-by-is-not-used/
http://stackoverflow.com/questions/10064532/the-order-of-a-sql-select-statement-without-order-by-clause