SoFunction
Updated on 2025-04-13

Asp Quick Development Method Data Operation Example Code Page 3/3


Of course you also write this as follows:
<%
sql="insert into cnarticle(cn_title,cn_author,cn_content) values(' "&whattitle&" ',' "&whoauthor&" ',' "&whatcontent&" ')"
opendatabase
(sql)
closedatabase
%>
Considering the possible deletion statement, we would write this:
sql="delect from cnarticle where id in(1,3,5,6,7,8)"

I created a new class DeldataTable and directly used (tableName, DelField,id) to complete the record deletion operation.
<%
Class DeldataTable
    dim tempvalue
    public Function DeldataSql(tableName,DelField,id)
        If tableName<>"" and id<>"" then
            sql="delete from "&tableName
            If isnumeric(id) and instr(id,",")=0 then
                sql = sql & " where "&DelField&" = "&id
            Else
                sql = sql & " where "&DelField&" in ("& id &")"
            End If
            Opendatabase
                (sql)
            Closedatabase
            tempvalue=true
        Else
            tempvalue=false
        End If
        DeldataSql=tempvalue
    End Function
End Class
%>
The following is my file, please add and delete it yourself
Copy code <%
'Used to query data
Class selectDataTable
'Search the record
    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
Previous page123Read the full text