Recommended: ASP instance: Instant display of the current page viewer ASP realizes instant display of the current page viewer number of people online.asp file is the referenced content: <!--#include file=dbconn.asp --><%onlineTimeout=10
This is my own experience, for you to refer to.
My goal is to make development simple, consider implementation statements as few as possible, and devote more energy to thinking about business logic. I hope my article will inspire and help you.
OK, let's get to the point:
Let’s take a look at the following examples:
| The following is the quoted content: <% db_path = database/cnbruce.mdb Set conn= Server.CreateObject(ADODB.Connection) connstr = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&Server.MapPath(db_path) conn.Open connstr Set rs = Server.CreateObject (ADODB.Recordset) sql = Select * from cnarticle rs.Open sql,conn,1,1 if rs.EOF and rs.BOF then response.write (No article yet) else Do Until rs.EOF response.write (the title of the article is:&rs(cn_title)) response.write(<br>Article author is:&rs(cn_author)) response.write(<br>The article is added to:&rs(cn_time)) response.write(<br>The content of the article is:&rs(cn_content)) response.write(<hr>) rs.MoveNext Loop end if rs.close Set rs = Nothing conn.close set conn=Nothing %> |
Well, this is a typical example of reading data and displaying it, see: http://www.cnbruce.com/blog/showlog.asp?cat_id=26&log_id=448
Well, it's really simple. From top to bottom, it's easy to understand. But when you read, insert, delete and modify multiple tables, and when there are a lot of HTML/js in your code, you will have a question: Why are there so many things to repeat?
So generally we separate some simple operations and write them into classes or functions and put them into include files.
Then we can use two files to implement the above operation:
conn.asp
| The following is the quoted content: <% db_path = database/cnbruce.mdb Set conn= Server.CreateObject(ADODB.Connection) connstr = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&Server.MapPath(db_path) conn.Open connstr %> |
showit.asp
| The following is the quoted content: <!--#include file=conn.asp --> <% Set rs = Server.CreateObject (ADODB.Recordset) sql = Select * from cnarticle rs.Open sql,conn,1,1 if rs.EOF and rs.BOF then response.write (No article yet) else Do Until rs.EOF response.write (the title of the article is:&rs(cn_title)) response.write(<br>Article author is:&rs(cn_author)) response.write(<br>The article is added to:&rs(cn_time)) response.write(<br>The content of the article is:&rs(cn_content)) response.write(<hr>) rs.MoveNext Loop end if rs.close Set rs = Nothing conn.close set conn=Nothing %> |
Reference: http://www.cnbruce.com/blog/showlog.asp?cat_id=26&log_id=448
Now it is relatively simple. If there are multiple operation pages, we just need to import the connection file, but it is still not concise enough. What is not concise?
I've been creating a server, writing close all the time, which makes it easy to make mistakes and looks too much to do with the content.
Share: ASP Tutorial: How to solve the timeout of ASP script running I'm learning server knowledge recently. Sometimes I encounter an error in which the asp script runs timeout, which is really troublesome. I found relevant information, and there are some solutions. The default script timeout of IIS is 90 seconds. If you upload software or transfer data more than 90 seconds.
4 pages in total Previous page 1234Next page