Data manipulation of ASP rapid development method

Source: Internet
Author: User
Tags add time end include sql reference

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



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.