Home > Net >  The DataTable receive Sql returned data sequence is random? !
The DataTable receive Sql returned data sequence is random? !

Time:10-03

I have a select query, using storage process paging and sorting, execute SQL alone, is to get to the normal order of the data, and then in the code, after returning to the datatable, dt data in order to change, and change is random, only manually again to sort the datatable;
The most strange is, only part of the data it is the case, and this part of the data with other types of data format of what are all the same,
Does anyone encountered a similar situation, please answer!!!!!!

CodePudding user response:

What is "only a portion of the data it is the case," returned by the query data is the data table, as long as the SQL in order is correct, there will be no order,

CodePudding user response:

Very strange question, I'm not met,

CodePudding user response:

If your storage process in the "right" sorting, so will not happen this phenomenon, if there should be a logical cause other, you can spin off other logic, only a few words to write a simple engineering test of extracting database code

CodePudding user response:

Use the storage process paging and sorting
So, if you do not pass the right sort parameters, the result is not obviously you expect
Because the datatable can be manual sorting

CodePudding user response:

Must be somewhere in the sorting, serious look at your own stored procedure code

CodePudding user response:

Emphasize:
Must have a definite order by SQL, the result is wants to order,
without the order by that the order is not controllable,

CodePudding user response:

I had this kind of circumstance, you carefully check, which inevitably the reorder,
If that is extracted from the database directly with ado.net, impossible to check a result, in the data to the program in another result
Also add do not add the order by some so-called, even if you don't add, the database will also try to give you a fixed default rules

Unless it is not, the order by you in the test, other people also constantly change index, the probability is too rate

CodePudding user response:

refer to 7th floor wang_peng_yl response:
I had this kind of circumstance, you carefully check, which inevitably the reorder,
If that is extracted from the database directly with ado.net, impossible to check a result, in the data to the program in another result
Also add do not add the order by some so-called, even if you don't add, the database will also try to give you a fixed default rules

Unless it is not, the order by you in the test, the other people also constantly change index, the probability is too rate
this probability is too late

CodePudding user response:

SQL statements to check the order?

CodePudding user response:

After the problem I have just met, recursive left two tables, in SQL directly executed two connections who left before the results are the same, but the datatable when receiving results C table in the received data sequence is random, B table in datatable results before normal (recursion is to sort)

CodePudding user response:

I found in SQL Server 2014 12.0.2269 version, no matter which table in datatable before receiving data sequence of works, using SQL Server 2014 12.0.2000 version will appear just said

CodePudding user response:

I also encountered such a situation, find the datatable js, find the "bSort" : true, this is the sort of datatable function, to false then did not appear the phenomenon of chaos sequence

CodePudding user response:

Small comrade problem solved, I because of an unrelated fields inside the value of the change data are affected by the query,
I had paging and sorting through stored procedures, return the content directly into the dataset but stored procedure execution directly inside the returned result is no problem, but beat him on the table after the inside of the data sorting is messed up, but another possibility is that affect the field value to delete all the light source, order will not be affected,
  •  Tags:  
  • C#
  • Related