• ----:)欢迎访问源码网(:----
    • 首页
    • 博客
    • 学院
    • 下载
    • 论坛
    • 影视
    • 发布源码
    • 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中五种连接数据库的方法
 
 

相关文章

 
 

百度搜索

 
 

asp获取表结构,并返回特定结果

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

只写了很简单的数据类型,对于更多的数据类型,请更改代码
<%
        Dim TblName : TblName = SafeSql(GetRequest("tbl","",1,0))%>
<form id="form1" name="form1" method="post" action="table.asp?action=show">
  <input type="text" name="tbl" id="tbl" value="<%=TblName%>" />
  <input type="submit" name="button" id="button" value="提交" />
</form>
<%
        Dim Action : Action = GetRequest("action","GET",1,0)
        If Action = "show" Then
                Call Show()
        End If
Sub Show()
        Dim Rs,i,iCount : Set Rs = ExecuteSql("select top 1 * from " & TblName)
        iCount = 0
        For i = 0 To Rs.Fields.Count - 1
                If iCount > 0 Then Response.Write ","
                Response.write Rs(i).Name
                iCount = iCount + 1
        Next
        Response.Write "<br />"
        For i = 0 To Rs.Fields.Count - 1
                Response.write i & "   " & Rs(i).Name & "<br />"
        Next
        Response.Write "<br />insert into " & TblName & "("
        iCount = 0
        For i = 0 To Rs.Fields.Count - 1
                If LCase(Rs(i).Name)<>"id" Then
                        If iCount > 0 Then Response.Write ","
                        Response.write Rs(i).Name
                        iCount = iCount + 1
                End If
        Next
        Response.Write ") values("
        iCount = 0
        For i = 0 To Rs.Fields.Count - 1
                If LCase(Rs(i).Name)<>"id" Then
                        If iCount > 0 Then Response.Write ","
                        If Rs(i).Type = 202 Then
                                Response.write "'""&" & Rs(i).Name & "&""'"
                        Else
                                Response.write """&" & Rs(i).Name & "&"""
                        End If
                        iCount = iCount + 1
                End If
        Next
        Response.Write ") <br />update " & TblName & " set "
        iCount = 0
        For i = 0 To Rs.Fields.Count - 1
                If LCase(Rs(i).Name)<>"id" Then
                        If iCount > 0 Then Response.Write ","
                        If Rs(i).Type = 202 Then
                                Response.write Rs(i).Name & "='""&" & Rs(i).Name & "&""'"
                        Else
                                Response.write Rs(i).Name & "=""&" &Rs(i).Name & "&"""
                        End If
                        iCount = iCount + 1
                End If
        Next
        Response.Write "where ID=""&ID<br />"
        For i = 0 To Rs.Fields.Count - 1
                If LCase(Rs(i).Name)<>"id" Then
                        Response.write "Rs(""" & Rs(i).Name & """) = " & Rs(i).Name & "<br />"
                End If
        Next
        Rs.Close : Set Rs = Nothing
End Sub
%>
------------------------------------------------------------------------------------------
结果
------------------------------------------------------------------------------------------
这个是将查询放进数组时,查询的字段
Id,Title,eName,Parent,Child,Url,Sort,UpImg,Content,Template,ArtTemp,PubDate,IsLock,ItemTemplate
对应的数组中某字段的索引号
0   Id
1   Title
2   eName
3   Parent
4   Child
5   Url
6   Sort
7   UpImg
8   Content
9   Template
10   ArtTemp
11   PubDate
12   IsLock
13   ItemTemplate
插入操作
insert into Mall_acata(Title,eName,Parent,Child,Url,Sort,UpImg,Content,Template,ArtTemp,PubDate,IsLock,ItemTemplate) values('"&Title&"','"&eName&"',"&Parent&","&Child&",'"&Url&"',"&Sort&",'"&UpImg&"',"&Content&","&Template&","&ArtTemp&","&PubDate&","&IsLock&","&ItemTemplate&")
更新操作
update Mall_acata set Title='"&Title&"',eName='"&eName&"',Parent="&Parent&",Child="&Child&",Url='"&Url&"',Sort="&Sort&",UpImg='"&UpImg&"',Content="&Content&",Template="&Template&",ArtTemp="&ArtTemp&",PubDate="&PubDate&",IsLock="&IsLock&",ItemTemplate="&ItemTemplate&"where ID="&ID
更新操作
Rs("Title") = Title
Rs("eName") = eName
Rs("Parent") = Parent
Rs("Child") = Child
Rs("Url") = Url
Rs("Sort") = Sort
Rs("UpImg") = UpImg
Rs("Content") = Content
Rs("Template") = Template
Rs("ArtTemp") = ArtTemp
Rs("PubDate") = PubDate
Rs("IsLock") = IsLock
Rs("ItemTemplate") = ItemTemplate

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

 

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

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