页面导航: 首页网络编程ASP编程ASP基础 → 正文内容

asp快速开发方法之数据操作实例代码第3/3页

发布:dxy 字体:[增加 减小] 类型:转载

当然你也这以这样写:
<%
sql="insert into cnarticle(cn_title,cn_author,cn_content) values(' "&whattitle&" ',' "&whoauthor&" ',' "&whatcontent&" ')"
opendatabase
conn.execute(sql)
closedatabase
%>
考虑到可能删除语句我们会这么写:
sql="delect from cnarticle where id in(1,3,5,6,7,8)"
我新建一个类DeldataTable,直接使用DeldataTable.DeldataSql(tableName,DelField,id)完成记录的删除操作。
<%
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
                conn.execute(sql)
            Closedatabase
            tempvalue=true
        Else
            tempvalue=false
        End If
        DeldataSql=tempvalue
    End Function
End Class
%>
以下是我的sql.asp文件,请自己进行增删
复制代码 <%
'用于查询数据
Class selectDataTable
    '查出记录
    public Function SelectData(sql)
        If sql<>"" then
            opendatabase
            Rs.open sql,conn,1,1
            If not Rs.eof then
                Thedata=Rs.GetRows(-1)
                Closedatabase
            Else
                Closedatabase
            End If
        End If
        SelectData=Thedata
    End Function
当前3/3页 上一页123
浏览次数:载入中... 打印本文关闭本文返回首页
·在百度中搜索关于“asp快速开发方法之数据操作实例代码”相关内容
·在谷歌中搜索关于“asp快速开发方法之数据操作实例代码”相关内容

文章评论

共有 位脚本之家网友发表了评论我来说两句

同 类 文 章
最 近 更 新
热 点 排 行