This is my own experience, for you to make a reference.
My goal is to make development simple, consider the implementation statements as little as possible, and devote more effort to thinking about business logic. I hope my article will inspire and help you.
Okay, let's get to the point:
Let's look at the following examples:
The following are the referenced contents: <% 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 ("article title is:" & RS ("Cn_title")) Response.Write ("<br> article author is:" & RS ("Cn_author")) Response.Write ("<br> article Add Time is:" & RS ("Cn_time")) Response.Write ("<br> article content is:" & RS ("Cn_content")) Response.Write ("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 showing 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 and Html\js multiple tables, when you have a lot of mixed in your code, you have a question: why are there so many things to repeat?
So we usually separate some simple operations, write classes or functions into include files (include).
So we can use the above two files to achieve the following:
Conn.asp
The following are the referenced contents: <% 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 are the referenced contents: <!--#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 ("article title is:" & RS ("Cn_title")) Response.Write ("<br> article author is:" & RS ("Cn_author")) Response.Write ("<br> article Add Time is:" & RS ("Cn_time")) Response.Write ("<br> article content is:" & RS ("Cn_content")) Response.Write ("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 relatively simple, if there are more than one operation page We just import the connection file can, but still not concise enough, where is not concise?
You've been creating the server, writing close all the time, so it's easy to go wrong, and it doesn't seem to have much to do with content.
Total 4 page: prev 1 [2] [3] [4] Next page