Caution data set

xiaoxiao2021-03-06  97

Recently, I have a thing to make a thing in about two days, and I will pay it today, but I always feel that there are some worry. Suddenly wanted to test the test, I originally wanted to test the data for data using two points, but I don't know how to get the Last Record and First Record, so I want to test the test slowly, how can I get the Last and First Record, but The actual test is scared. The ASP dataset is likely to mess.

Previously, when writing ASPs read data, always select data directly with "SELECT * from Table", then use

IF not r.

Rs.movelast

Do While Not rs.bof then

Response.write RS ("ID")

.....

Loop

END IF

Simply put, use a loop to directly read all databases, but if the data has tens of thousands of words, the speed is imagined, so I want to choose the data on the data with two-point method, but I don't know how to get started. And the final data, I thought about rs.bof? Rs.eof originally thought how to get the maximum value, minimum value of the field ID, and then better, but found in actual operation, if you use the following things, not necessarily Get maximum and minimum:

If NOT RS.BOF THEN RS.MOVEFIRST FRSID = RS ("ID") end ififf not rs.eof the rs.movelast lstid = rs ("id") Endnesso while not rs.Bof response.write "ID is" & rs ("ID") & "rs.movepreviousloop

Response.write "first id =" & frsid & "" response.write "Last ID =" & lstid & "

FRSID = 6, LSTID = 15, but there is a data of the data in the displayed data to 16, which is to say the biggest ID! = LSTID (I always think this is what I want to wait), and finally checking is that the SQL statement has a problem, and when it is changed to "select * from login order by ID ASC", display:

ID IS 16ID IS 15ID IS 14ID IS 13ID IS 12ID IS 11ID IS 10ID IS 8ID IS 7ID IS 6First ID = 6LAST ID = 16 When SQL is changed to Select * from login order by id desc ", it is:

ID IS 6ID IS 7ID IS 8ID IS 10ID IS 11ID IS 12ID IS 13ID IS 14ID IS 15ID IS 16FIRST ID = 16LAST ID = 6

The arrangement of the two data is completely unlimited in SQL (which is DESC, which is DESC, and the realistic ASC of DESC), and the data displayed and the login table is completely different. .

Conclusion: The arrangement of data is completely controlled by both SQL and Recordset. When you don't have a pointer logging, the pointer record is chaos, it is best to organize the data in the data operation, so it can be arranged in order to operate in order. ?

转载请注明原文地址:https://www.9cbs.com/read-124230.html

New Post(0)