• ----:)欢迎访问源码网(:----
    • 首页
    • 博客
    • 学院
    • 下载
    • 论坛
    • 影视
    • 发布源码
    • RSS
    • ITPig
    • 笑话网
    • 百家姓
    • 繁體中文

源码网 - 中国第一源码门户
选择镜像:网通镜像 - 电信主站
  • 首 页
  • 新闻动态
  • 网站运营
  • 网页制作
  • WEB开发
  • 编程开发
  • 图像媒体
  • 操作系统
  • 数据库
  • 服务器
热门搜索 优化 SEO 故事 cms IIS7 MySQL 个人 AdSense 主题推广 | 文章搜索: 高级搜索
会员登录/控制面版您的位置: 学院首页 >> WEB开发 >> ASP开发 >> 数据库相关 >> 详细内容
 

推荐文章

 
 

热点文章

  • ASP访问ACCESS出错提示简要解释
  • ASP如何使用MYSQL数据库
  • ASP连接数据库的几种方式
  • Access转Excel AND Excel导入ACC 代码
  • WEB.CONFIG中ACCESS数据库连接
  • 从数据表中取出第n条到第m条的记录的方法
  • asp连接sybase
  • 较简单的后台管理
  • ASP中调用存储过程、存储过程语法、存储过程写法-sql..
  • 删除全部数据的最快捷的方法
  • ASP数据库操作类“MC.DBOC”
  • ASP中五种连接数据库的方法
 
 

相关文章

  • 删除MySql注册到系统的服务
  • 修改MySQL的字符集
  • 修改MySQL密码的方法
  • 欧盟:搜索引擎公司必须在6个月之内删除用户搜索资料
  • 修改,审核,删除,ASP 代码
  • NBA要求中国视频网站删除NBA相关内容
  • MySQL V4.1.13列表
  • MySQL查询的性能优化
  • MySQL入门学习(六)修改和备份、批处理
  • 修改SQL Server 2005执行环境
  • 50种方法优化SQL Server数据库查询
 
 

百度搜索

 
 

asp同一个文件操作数据表,添加、删除、修改、列表、查询

  • 阅览次数:
  • 文章来源: 落伍者
  • 原文作者: jhtfh
  • 整理日期: 2008-08-09
  • 发表评论
  • 字体大小:
  • 小
  • 中
  • 大

<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/Inc_Functions.asp"-->
<!--#include file="../inc/Inc_SystemFun.asp"-->
<!--#include file="../inc/Inc_Common.asp"-->
<!--#include file="Admin_Check.asp"-->
<%
'检测是否有管理标签选项的权限
        If Not ChkFlag("selectcata") Then
                Call WriteSystemLog("标签选项类别管理","权限不够。")
                Call ShowJsMsg("权限不够","history.back();") : Response.End()
        End If
'权限管理没有写完
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>标签选项类别管理</title>
<link href="Images/Manage/Manage.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="Admin_Js.js"></script>
</head>
<body>
<div id="BodyContent"><div id="BodyNav"><div id="PageLoc">当前位置 &gt;&gt; <a href="Admin_SelectValue.asp">标签选项管理</a> &gt;&gt; 标签选项分类管理</div><div id="PageNavBar"><ul>
                                <li><a href="Admin_SelectCata.asp?action=edit">添加分类</a></li>
                                <li><a href="Admin_SelectCata.asp">分类管理</a></li>
                        </ul></div></div>
<div id="BodyWork">
<%
Select Case GetRequest("action","GET",1,0)
        Case "del"
                Call Del()
        Case "edit"
                Call Edit()
        Case "save"
                Call Save()
        Case Else
                Call Main()
End Select
%></div></div>
<%
Sub Del()
        Dim Sql,Rs,ID
        ID = GetRequest("ID","GET",0,0)
        Sql = "select top 1 * from "&Table_Name&"_SelectCata where ID=" & ID
        If IsNull(ID) Or Not IsNumeric(ID) Then Sql = ""
        If Sql <> "" Then
                Set Rs = ExecuteSql(Sql)
                If Not Rs.Eof Then
                        If ExecuteSql("select count(*) from "&Table_Name&"_SelectValue where SelectCata="&ID)(0)>0 Then
                                ShowAlertMsg "系统提示","删除失败,存在日志正在使用该分类。","",450
                        Else
                                ExecuteSql "delete from "&Table_Name&"_SelectCata where ID=" & ID
                                ShowAlertMsg "系统提示","删除成功。","",450
                                Call WriteSystemLog("标签选项类别管理","删除成功,ID:"&ID&"。")
                        End IF
                Else
                        ShowAlertMsg "系统提示","删除失败找不到指定的记录。","",450
                End IF
                Rs.Close
                Set Rs = Nothing
        Else
                ShowAlertMsg "系统提示","删除失败找不到指定的记录。","",450
        End If
End Sub

Sub Main()
        Call WriteSystemLog("标签选项类别管理","标签选项类别管理。")
        'display the list
        Dim RsArr,Sql,sPage,sKey,sPageSize,sSearch,sCount,sPageCount,i
        sPageSize = 25
        sPage = CLng(Request.QueryString("page"))
        sKey = Trim(Request("sKey"))
        sSearch = ""
        If sKey <> "" Then
                sSearch = " and Title like '%"&SafeSql(sKey)&"%'"
        End If
        sCount = ExecuteSql("select count(*) from "&Table_Name&"_SelectCata where 1=1 "&sSearch&"")(0)
        sPageCount = Fix(sCount / sPageSize)
        If sCount Mod sPageSize <> 0 Then sPageCount = sPageCount + 1
        If sPage>sPageCount Then sPage = sPageCount
        Sql = "select top "&sPageSize&" ID,Title,SelectType from "&Table_Name&"_SelectCata where 1=1 "&sSearch&" order by id desc"
        If sPage > 1 Then
                Sql = "select top "&sPageSize&" ID,Title,SelectType from "&Table_Name&"_SelectCata where 1=1 "&sSearch&" and id not in(select top "&(sPage-1)*sPageSize&" id from "&Table_Name&"_SelectCata where 1=1 "&sSearch&" order by id desc) order by id desc"
        End If
        RsArr = RsResult(Sql)
            %><div id="CataArea">
<div id="Search"><form action="Admin_SelectCata.asp" name="sch" method="post">标题关键字<input name="skey" id="skey" style="width:80px;" /> <input type="submit" class="Btn_Ok" name="Submit" value="搜索" /></form></div>
<ul><%=GetSelectCataList(CataID)%></ul><div class="clear"></div></div>
<table width="100%" cellpadding="3" cellspacing="1"><tr class="MainTableBg"><td>编号</td><td>名称</td><td>选项类别</td><td>管 理</td></tr><%
        If IsArray(RsArr) Then
            For i = 0 To UBOUND(RsArr,2)
                %><tr class="MainTd"><td><%=RsArr(0,i)%></td><td><%=RsArr(1,i)%></td><td><%if RsArr(2,i)=1 then%>单选<%else%>多选<%end if%></td><td><a href="Admin_SelectCata.asp?ID=<%=RsArr(0,i)%>&action=edit">编辑</a> <a href="Admin_SelectCata.asp?ID=<%=RsArr(0,i)%>&action=del" onClick="return Confirm('是否删除');">删除</a></td></tr>
                <%
            Next
            Erase RsArr
        End If
            %></table><%
        Response.Write "<div id=""Pager""><ul>"
        Response.Write GetPageBar(sPage,sPageCount,"Admin_SelectCata.asp?page={i}&sKey=" & sKey)
        Response.Write "</ul></div>"
End Sub

Sub Save()
        Dim ID,Title,SelectType
        ID = GetRequest("ID","GET",0,0)
        Title = SafeSql(GetRequest("Title","",1,20))
        SelectType = GetRequest("SelectType","GET",0,0)
        If Not IsNumeric(ID) Then ID = 0
        If Title = "" Then ShowAlertMsg "系统错误","分类名称不能为空!","",450:Exit Sub
        Dim Sql,iCount
        Sql = "select count(*) from "&Table_Name&"_SelectCata where Title='"&Title&"' and id<>" & ID
        If ID = 0 Then Sql = "select count(*) from "&Table_Name&"_SelectCata where Title='"&Title&"'"
        iCount = ExecuteSql(Sql)(0)
        If iCount = 0 Then        '可编辑,添加和修改
                Sql = "update "&Table_Name&"_SelectCata set Title='"&Title&"',SelectType="&SelectType&" where ID=" & ID
                If ID = 0 Then Sql = "insert into "&Table_Name&"_SelectCata(Title,SelectType) values('"&Title&"',"&SelectType&")"
                ExecuteSql Sql
                Call WriteSystemLog("标签选项类别管理","添加、编辑标签选项类别,'"&Title&"'。")
        Else
                ShowAlertMsg "系统错误","已经存在该分类!","",450:Exit Sub
        End If
        Response.Redirect "Admin_SelectCata.asp"
End Sub

Sub Edit()
        Dim Sql,Rs,ID
        ID = GetRequest("ID","GET",0,0)
        Call WriteSystemLog("标签选项类别管理","添加、编辑标签选项类别,ID:"&ID&"。")
        Sql = "select top 1 * from "&Table_Name&"_SelectCata where ID=" & ID
        If IsNull(ID) Or Not IsNumeric(ID) Or ID = 0 Then Sql = ""
        Dim Title,SelectType
        Title = "" : SelectType = 1
        If Not Sql = "" Then
                Set Rs = ExecuteSql(Sql)
                If Not Rs.Eof Then
                        Title = Rs("Title")
                        SelectType = Rs("SelectType")
                Else
                        ID = 0
                End If
                Rs.Close
                Set Rs = Nothing
        Else
                ID = 0
        End If
        %>
<table width="100%" cellpadding="3" cellspacing="1"><form name="AForm" method="post" action="Admin_SelectCata.asp?ID=<%=ID%>&action=save"><tr class="MainTableBg"><td colspan="2">标签选项分类管理</td></tr>
<tr><td class="MainTd2" width="240">分类名称</td><td class="MainTd"><input type="hidden" name="ComeUrl" value="<%=FilterHtml(GetComeURL())%>" /><input type="text" name="Title" value="<%=FilterHtml(Title)%>" /></td></tr>
<tr><td class="MainTd2" width="240">选项类型</td><td class="MainTd"><input type="radio" class="inputCheckBox" name="SelectType" value="1"<%If SelectType=1 Then%> checked="checked"<%End If%> id="IsLock1" /><label for="IsLock1">单选</label> <input type="radio" class="inputCheckBox" name="SelectType" value="0"<%If SelectType=2 Then%> checked="checked"<%End If%> id="IsLock2" /><label for="IsLock2">多选</label></td></tr>
<tr><td class="MainTd2" colspan="2"><input type="submit" class="Btn_Ok" value="提交" name="bt_ok" /> <input type="reset" class="Btn_Cancel" value="取消" name="bt_cancel" /></td></tr></form></table>
        <%
End Sub
%>
</body>
</html>
<%
Call PageBottom()
%>

上一篇:PayPal全中文详解
下一篇:PHP初级程序员面试题及答案
  • 网友评论:
  • 查看所有评论
  • 我要发表评论
您的网名:
留言主题:
你要发表的内容:

 

关于本站 | 广告联系 | 版权声明 | 网站地图 | 发布软件 | 帮助中心 | 源码论坛

Copyright © 2005-2007 CodePub.Com  程序支持:木翼  滇ICP备05005971号