Tutorials to .com

Tutorials to .com » Asp » Optimization » Comment on "<in the ASP page to improve the dynamic performance of>> less than with the proposed amendment

Comment on "<in the ASP page to improve the dynamic performance of>> less than with the proposed amendment

Print View , by: iSee ,Total views: 9 ,Word Count: 1602 ,Date: Fri, 17 Apr 2009 Time: 10:34 PM

Comment on "<in the asp page to improve the dynamic performance of>> less than with the proposed amendment

Oh, you can enter the essence of the district? I spent one day.
two of the <<in the ASP page to improve the dynamic performance of>> a text, a source of inspiration to me, wish to express my gratitude, but I want to still have some shortcomings.

One is unable to respond to some of the information with the update.
Is set up as a BBS, then update the information at any time
Click on each of the posts
Post new information, these two brotherprogram can not automatically update, only users can use to change the query.

The second is to use too much memory, in fact, a forum for speaking, the majority of people in order to visit, there is no need for each one session.

Third, it is inconvenient to deal with data
Can only be used for an array of ways, not intuitive, poor readability.

For the above, I propose a program to improve the use of the following application, can be achieved using the same data more than two and out into the ID number, other data select a second
Third, the application automatically delete out-dated in order to save memory.
Four in the add and remove data, re-import data

Ha ha other benefits, you can use getstring (), and will not work when the original page can be 1,3, and

Code is as follows

-------------------------------------------------- ---------------'
dim apage_pagesize 'number of records per page
dim apage_Count 'Total number of records
dim apage_PageCount 'the total number of pages
dim apage_PageForm 'jump page with the Form
dim apage_PageUrl 'link Previous Next
dim apage_timeout 'expiration time setting (seconds)

apage_timeout = 300 'set the expiration time (in seconds)
apage_pagesize = 20 '

function apage_bactive (str_name) 'to determine whether this object, and delete expired objects
apage_bactive = false
dim item, s_temp
for item = 1 to Application.contents.count 'to find all the application
s_temp = Application.contents (item)
if isarray (s_temp) then
if ubound (s_temp) = 3 and s_temp (0) = "apage" then
if s_temp (1) = str_name then
apage_bactive = true 'request object exists
if DateDiff ( "s", s_temp (2), now ())> apage_timeout then 'delete off the target
Application.contents.remove (item)
end if
end if
end if
end if
end function 'b_inuser

sub apage_open (str_name, str_table, str_id, str_sqlend) 'Open the object and calculate the number of data
'Object names, table names, keywords, and query
dim a1, a_ob
if not apage_bactive (str_name) then 'If the object does not exist then a new object
apage_load str_name, str_table, str_id, str_sqlend
end if
a1 = application (str_name)
a1 (2) = now ()
application (str_name) = a1
a_ob = a1 (3)
apage_Count = ubound (a_ob, 2) +1
apage_PageCount = int (apage_Count / apage_pagesize) +1
end sub'apage_open

function apage_get (str_name, page) 'get all the id number on this page
dim a1, a_ob, i_stat, i_end, i1, str_actionurl, str_query, str_1, str_2
'In order to ensure the following is the correct page
page = cint (page)
if page <1 then page = 1
if page> apage_PageCount then page = apage_PageCount

'Get id number
apage_get = ""
a1 = application (str_name)
a_ob = a1 (3)
i_stat = (page-1) * apage_pagesize
i_end = page * apage_pagesize-1
if i_end> (apage_Count-1) then
i_end = apage_Count-1
end if

for i1 = i_stat to i_end
apage_get = apage_get & a_ob (0, i1) & ","
'Remove the extra "," No.
if len (apage_get)> 0 then
apage_get = left (apage_get, len (apage_get) -1)
end if

'In other words the following pages to get user information
str_actionurl = "http://" & Request.ServerVariables ( "HTTP_HOST") & Request.ServerVariables ( "SCRIPT_NAME")
str_query = Request.ServerVariables ( "QUERY_STRING")
str_1 = split (str_query, "&")
str_query = ""
for i1 = 0 to ubound (str_1)
if left (str_1 (i1), 5) <> "page =" then
response.write left (str_1 (i1), 5) & "<br>"
str_query = str_query & str_1 (i1) & "&"
end if
str_2 = str_actionurl & "?" & str_query
if page> 1 then
apage_PageUrl = "<a href=" &str_2 & "page=1" &"> Home </ a>" & _
"<a href="&str_2 & "page="&(page-1) &"> page </ a>"
apage_PageUrl = "Home page"
end if
if page <apage_PageCount then
apage_PageUrl = apage_PageUrl & "<a href="&str_2 & "page="&(page+1) &"> page after the </ a>" & _
"<a href="&str_2 & "page="&apage_PageCount&"> Last </ a>"
apage_PageUrl = apage_PageUrl & "after the page footer"
end if
apage_PageForm = "<table> <form method=get name='page' onsubmit='document.location =""" & str_2 &"page=""+this.page.value;return false;'>" & _
"<tr> <td> go <INPUT TYPE='text' NAME='page' value='"&page&"'> page" & _
"<INPUT Type=submit style='font-size: 9pt' value=GO> </ table>"

end function

sub apage_load (str_name, str_table, str_id, str_sqlend) 'into a new or re-target

sql = "select" & str_id & "from" & str_table & str_sqlend
set rs = conn.execute (sql)
dim a2 (3)
a2 (0) = "apage"
a2 (1) = str_name
a2 (2) = now ()
a2 (3) = rs.getrows ()
application (str_name) = a2
end sub'apage_load

sub apage_update (str_name, str_table, str_id, str_sqlend) 'update the data used
if apage_bactive (str_name) then 'If the object is re-import the object exists
apage_load str_name, str_table, str_id, str_sqlend
end if
end sub


By-laws: test.asp
-------------------------------------------------- --------------------
<!--# include file = "conn.asp" ->
<!--# include file = "a_page.asp" ->
'Build table
'create table page
'(page_id INT not null IDENTITY (1, 1),
'page_value int not null,
'class_id int not null
sub add_test 'accession to the test data
dim i1'as int
for i1 = 0 to 1000
sql = "insert into page (page_value, class_id) values (" & i1 & ", 1)"
conn.execute sql
for i1 = 0 to 1000
sql = "insert into page (page_value, class_id) values (" & i1 & ", 2)"
conn.execute sql
apage_update "test", "page", "page_id", ""
'apage_update "test1", "page", "page_id", "where class_id = 1"
end sub 'add_test
'add_test' to remove the accession '

dim str_test
apage_open "test", "page", "page_id", ""
'apage_open "test1", "page", "page_id", "where class_id = 1"
str_test = apage_get ( "test", request ( "page"))
'str_test = apage_get ( "test1", request ( "page"))
sql = "select * from page where page_id in (" & str_test & ")"
set rs = conn.execute (sql)
response.write response.write "<table border=1> <tr> <td>" & rs.getstring (2,, "<td>", "<tr> <td>") & "</ table>"
'while not rs.eof
'Response.write "<a href=hahafish.asp?id=" & rs("page_id") & ">" & rs ( "page_value") & "</ a> <br>"

response.write apage_PageUrl
response.write apage_pageform

Asp Optimization Articles

Can't Find What You're Looking For?

Rating: 0.0


No comments posted.