"If not rs.eof and is Rs.bof then" how to understand? See ASP instance

Source: Internet
Author: User
Tags dsn table name trim zip access database oracle database
who can explain in detail the ASP "if not rs.eof and not Rs.bof then" how to understand?2007-06-10 21:11 zhbxj2002 |  Category: Other programming Languages | Browse 4,349 Times
Who can explain in detail the ASP "if not rs.eof and not Rs.bof then" how to understand?

Rs.eof=true indicates that the pointer has moved to the last record and cannot be moved down (not equal to the last record)

rs.bof=true when the table pointer has moved to the top record, cannot move up (again, unequal is the first record)

set a database a total of 7 records, when in article n (n=1,2,,,, 7),
Rs.bof=false,rs.eof=false
but the first, but also move up, rs.bof=true, indicating that the same can not be moved up to
understand rs.eof

if not Rs.eof 
   and not Rs.bof then statement block
End If
is:
executes the statement block as long as it has not reached the top and bottom of the data
Example::

ASP and database-connect, write, modify, delete, display code properties and methods

        PageCount Properties: Determines how many "pages" of data the Recordset object includes.         here the "page" is a collection of data records, the size equals the setting of the PageSize property, even though the last page has fewer records than the PageSize value, the last page is considered A page of PageCount. It is important to note that this property is not supported by all data providers.     PageSize Properties: Displays the number of records displayed on each page of the Recordset object. The            PageSize property is the key to how the paging is displayed when ADO accesses the database, and it can be used to determine how many records compose a logically "one page". Sets and establishes the size of a page, allowing the use of the AbsolutePage property to move to the first record of another logical page. The PageSize property can be set at any time.   RecordCount Properties: Displays the total number of Recordset object records.   Rs. RecordCount: The total number of data records in the cursor.   Rs. MoveFirst: Points to the first record.            Rs. Move (6): Move to 6th record.   Rs. MoveLast: Points to the last record.   Rs. MovePrev: Points to the previous record.   Rs. MoveNext: Points to the next record.   Rs. GetRows: Put the data in the array

The open function of the Recordset object: Rs.Open data table name or SQL instruction, connection object, Recordset type, lock type parameter one: If the data table name is specified, the entire data table is opened, and if specified as a select command,  The Recordset object that is created is the result of the data record selected by the Select command.  Parameter two: A connection object that is passed in to an open database. Parameter three: is the recordset type, it contains four kinds of setting values of the following table: Recordset type set value meaning adOpenForwardOnly (=0) Read only, and the current data record can only move Down adOpenStatic (=3) read-only,  The current data record can be freely moved adOpenKeyset (=1) can read and write, the current data record can freely move adopendynamic (=2) can read and write, the current data record can be moved freely adOpenKeyset and adopendynamic differ only in the case of multiple people sharing the database, if you open the data table in adOpenKeyset mode, you cannot see other people's new data records (unless you restart).  If you open the database in adopendynamic mode, you can see other people's new data records. Parameter four: is the lock type, it also contains four sets of values, see the following table: Lock type setting value meaning adLockReadOnly (=1) default value, used to open a read-only data record adlockpessimistic (=2) pessimistic locking adlockoptimistic ( =3) Optimistic locking adlockbatchoptimistic (=4) batch optimistic lock

Database connection--------------------------------MS Access database connection

Connect with DSN and no user name and password:

<% set Conn=server.createobject ("ADODB. Connection ") Conn.Open" Yourdsnname "%>

Connect with a DSN and have a username and password:

<% set Conn=server.createobject ("ADODB. Connection ") Conn.Open" Yourdsnname "," username "," password "%>

Connect using the actual database absolute path:

<% Set conn=server.createobject ("ADODB. Connection ") strconn=" Driver={microsoft Access DRIVER (*.mdb)}; "Strconn=strconn &" Dbq=e:\yanhang\database.mdb "Conn. Open strconn%>

Connect using the actual database relative path:

<% Set conn=server.createobject ("ADODB. Connection ") strconn=" Driver={microsoft Access DRIVER (*.mdb)}; "Strconn=strconn &" dbq= "& Server.MapPath ("/database/yanhang.mdb ") Conn. Open strconn%>

MS SQL Server database connection

Connect using DSN:

<% set Conn=server.createobject ("ADODB. Connection ") Conn.Open" DSN=MYDSN; Uid=user; Pwd=password;database=databasename "%>

No DSN connection:

<% Set conn=server.createobject ("ADODB. Connection ") dsntemp=" Driver={sql Server}; Server=servername; Uid=user; Pwd=password;database=databasename "Conn.Open dsntemp%>

Oracle Database connection:

<% set Conn=server.createobject ("Adodb.connection") conn.cursorlocation=aduseclient DSNTemp= "Provider=MSDAORA.1 ; password=xxxxx; User id=yanhang;data source=xxx.world "Conn.Open dsntemp%>

The data is written ..... ..... ..... ..... ..... .................. ..... ..... ..... ..... ..... ............. .......... <!--#i nclude file= "common/conn.asp"-<% set Rs=server.createobject ( "Adodb.recordset") sql= "select * from online" Rs.Open sql,conn,3,2 rs.addnew rs ("name") =request ("name") RS ("Tel") = Request ("Tel") rs ("fax") =request ("Fax") rs ("Mail") =request ("email") RS ("code") =request ("Zip") rs ("content") = Request ("Contents") RS ("Address") =request ("Address") Rs.update rs.close%>

Data modification ..... ..... ..... ..... ....................... ..... ..... ..... ..... ..... ............. .......... <% if request ("action") = "edit" then "decide whether to modify

' Get form-passed data Member_name=trim (Request.Form ("Member_name")) Member_pwd=trim (Request.Form ("Member_pwd")) question= Trim (Request.Form ("question")) Answer=trim (Request.Form ("answer")) Realname=trim (Request.Form ("Realname")) sex= Trim (Request.Form ("Sex")) Zip=trim (Request.Form ("Zip")) Address=trim (Request.Form ("Address")) Tel=trim ( Request.Form ("tel")) Fax=trim (Request.Form ("fax")) Mobile=trim (Request.Form ("mobile")) Email=trim (Request.Form (" Email ") Web=trim (" Request.Form (")) Vip=request.form (" VIP ") Remark=trim (Request.Form (" remark "))

Sql= "SELECT * from member where m_id=" &m_id set Rs=server.createobject ("Adodb.recordset") Rs.Open sql,conn,1,3

RS ("Member_name") =member_name rs ("answer") =answer RS ("question") =question rs ("Member_pwd") =member_pwd rs ("Realname ") =realname rs (" Sex ") =sex rs (" Zip ") =zip RS (" tel ") =tel rs (" mobile ") =mobile RS (" fax ") =fax rs (" Address ") =address RS (" Email ") =email RS (" Web ") =web rs (" VIP ") =vip RS (" remark ") =remark

Rs.update Rs.close Set Rs=nothing

Call OK ("data modified successfully. "," edit_member.asp?m_id= "&m_id)

End If%>

Data deletion--numeric fields ..... ..... ..... ..... ..... ..... ................ ..... ..... ..... ..... ..... ............... ......... <% set Rs=server.createobject ("Adodb.recordset") sql= "SELECT * from Pay where ID =1 "Rs.Open sql,conn,1,3 if not rs.eof and is Rs.bof then Rs.movefirst does while not rs.eof Rs.delete Rs.movenext Loop End If Rs.close%>

Data deletion--string field ..... ..... ..... ..... ..... ..... ................ ..... ..... ..... ..... ..... ............... ......... <% set Rs=server.createobject ("Adodb.recordset") sql= "SELECT * FROM Pay where Namer = ' aaa ', Rs.Open sql,conn,1,3 if not rs.eof and not Rs.bof then Rs.movefirst does while not rs.eof Rs.delete Rs.movenext Loop End If Rs.close%>

The data show ... ..... ..... ..... ..... ..... ..... ..................-...... .... <% lei= "Industry News" setting displays the information category set Rs=server, which is ....... ..... ..... .....???????.. CreateObject ("ADODB. Recordset ") sql=" select Top * from News where Lei <> ' "&Lei&" ORDER by ID Desc "Rs.Open sql,conn,1,1 if Rs.eof Then ' judge if there is no information in the database, prevent read error%> no information! <% else do and not rc.eof%> <%if len (rs ("title")) > Ten Then Response.Write Left (RS ("title"), & "..." Else Response.Write rs ("Title") End if%> <% ' Loop display data Rc.movenext loop rc.close set rc=nothing end if%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.