Now we can write this:
<!--#include file="" -->
<%
sql = "Select * from cnarticle"
opendatabase
sql,conn,1,1
If not then
Do Until
("The title of the article is:"& rs("cn_title"))
("<br>The author of the article is: "& rs("cn_author"))
("<br>The article was added to: "& rs("cn_time"))
("<br>The content of the article is: "& rs("cn_content"))
("<hr>")
Loop
else
("No article yet")
end if
Closedatabase
%>
Well, we have written less, is this the easiest thing? Of course not! It can be easier.
Use GetRows to pass the query data to a variable, and use the ubund method to obtain the number of data records.
not understand? It's OK, let's continue to read:
Create another file:
<%
Class selectDataTable
public Function SelectData(sql)
If sql<>"" then
opendatabase
sql,conn,1,1
If not then
Thedata=(-1)
Closedatabase
Else
Closedatabase
End If
End If
SelectData=Thedata
End Function
End Class
%>
Well, just copy it, now we can simply write it like this:
<!--#include file="" -->
<!--#include file="" -->
<%
sql = "Select * from cnarticle"
set loadData=new selectDataTable
Thedata=(sql)
If isarray(Thedata) then
Num=ubound(Thedata,2)
for i=0 to Num
("The title of the article is:"&Thedata(1,i))
("<br>The author of the article is:"& Thedata(2,i))
("<br>The data(3,i))
("<br>The content of the article is:"& Thedata(4,i))
("<hr>")
next
else
("No article yet")
End If
%>
Haha, in this way, we can complete the reading of the data with just two sentences. Similarly, by adding
<%
public Function SelectDataNum(sql)
If sql<>"" then
Opendatabase
sql,conn,1,1
If not then
Thedata=(-1)
Closedatabase
Num=ubound(Thedata,2)
Else
Closedatabase
End If
End If
SelectDataNum=Num
End Function
%>
We can use
<%
sql = "Select * from cnarticle"
set loadData=new selectDataTable
Num=(sql)
%>
To obtain the number of records, it can be used to determine whether the page is duplicated or whether the user name is duplicated.
For other operations on data records, we create a new class and use UpdateTable to complete the operation:
<%
Class UpdataTable
public Function UpdataSql(sql)
If sql<>"" then
Opendatabase
(sql)
Closedatabase
End If
End Function
End Class
%>
<%
sql = "delete from cnarticle"
set UpdateDate=new UpdataTable
(sql)
%>
Previous page123Next pageRead the full text