The ASP reads the last record in the database

Updated on technology 2024-03-27
10 answers
  1. Anonymous users2024-02-07

    When the database adds data, it will automatically put the last OID+1, that is to say, you have ten pieces of data, and then after you add a piece of data, the OID will automatically turn back to 11, don't worry about this, if you are talking about reading the last piece of information in the database, there are 2 methods, one is to read the database with SQL statements, and then arrange them in descending order according to the OID, and then the output data is the last record, and the other is to read the database, in ascending order, and then move the pointer to the endto read the last record:

    set rs = "adodb,recordset")sql="select * from object order by oid asc"

    sql,conn,1,1

    rs("oid")

    set rs =nothing

    Or. set rs = "adodb,recordset")sql="select * from object order by oid desc

    sql,conn,1,1

    rs("oid")

    set rs =nothing

  2. Anonymous users2024-02-06

    There are no examples, I'm not doing ASP.

    Get the last record like this.

    select top 1 oid from object order by oid desc

    In the client, you can use this variable to store the OID, and when adding, you can use this variable +1 to display.

  3. Anonymous users2024-02-05

    1. sql = "select top 1 * from mpce order by id desc"

    2.It is recommended that you adopt this structure:

    set rs="")

    sql="select * from mpce"

    sql,conn,1,3

    rs("data1")=trim("data1"))rs("data2")=trim("data2")).

    set rs=nothing

    with

  4. Anonymous users2024-02-04

    There is no such statement

    You can only use the movenext loop to move to the next record until the last record

  5. Anonymous users2024-02-03

    movelast

    Method of the recordset object:

    Moves the record pointer down one line from its current position.

    Moves the record pointer up one line from its current position.

    Move the record pointer to the first row of the data table.

    Move the record pointer to the last row of the data table.

    Move the record pointer to row n n of the data table.

    Move the record pointer to the first line of page n.

    Set each page to n records.

    Returns the total number of pages based on the setting of pagesize.

    Returns the total number of records.

    Returns whether the record pointer exceeds the end of the data table, true indicates yes, false indicates whether the record pointer exceeds the end of the data table, true indicates yes, and false indicates that the current record is deleted, but the record pointer will not be moved downward.

    Add a record to the end of the data table.

    Update the datasheet records.

    rs can only be queried in one direction. With movefirst and then movelast, it is easy to make mistakes.

  6. Anonymous users2024-02-02

    Let's say the four classified channels are: Politics, Economics, Culture, Sports.

    select top 1

    select top 1 headline from politics order by time desc )as latest political news, select top 1 headline from economy order by time desc )as latest economic news, select top 1 headline from culture order by time desc )as latest culture news, select top 1 headline from sports order by time desc )as Latest sports news.

    from Politics.

    Display effects. Latest Political News, Latest Economic News, Latest Cultural News, Latest Sports News.

    The opening of the 17th National Congress of the Communist Party of China, the impact of the economic crisis, the opening of the cultural festival, the opening of the World Cup.

    -asp page--- set your database name and four table names, the article publication time, and you can use the ---

    Politics: <%=news1%>

    Economic sector: <%=news2%>

    Culture section: <%=news3%>

    Sports: <%=news4%>

  7. Anonymous users2024-02-01

    select top 1 * form db wehre? order by id desc 'How to sort, you see for yourself.

    The value obtained is the last one.

  8. Anonymous users2024-01-31

    <%'Database connection file ......

    <%'Read the last id value.

    sql="select id from user order by id desc "

    set rs=

    Outputs the last ID

    rs("id")

    Closing the database connection is ......

    The first floor is also correct.

  9. Anonymous users2024-01-30

    id="select max(id) from the table name")(0)

    That's the ID you want

  10. Anonymous users2024-01-29

    1. Add an auto-added field to the data table in your access database, such as IDX

    2态select top 1 from table_name order by idx desc;

    - Above, I hope it helps you.

Related questions
10 answers2024-03-27

select * from table name where lab='101'and name='Sulfuric acid', don't know your table structure, so to give you the simplest select, you can talk about your table structure.

12 answers2024-03-27

In order, remember to turn it off when you are finished.

3 answers2024-03-27

At least the basic things must be mastered, such as: the linear structure of the database, the storage method, the way to call Hezheng, and the operation of the table in the database (to use statements to erect the bench to achieve). >>>More

6 answers2024-03-27

The prospect of learning UI is good, and there are many training institutions, so the local people may choose to visit and understand the real teachers and educational strength of the school before making a choice. Share the general development of the UI, I hope it will be useful to you. >>>More

11 answers2024-03-27

The deletion operation in the data is irreparable, sometimes the data in the data table may be deleted due to misoperation, or the database crashes for other reasons, and all the data is lost, especially when there is a large amount of useful data in the database, then it is impossible for you to enter the data again from the beginning, this is the role of the backup database, back up the database, when the above situation occurs, you can restore the previous database through the backup file.