模板天下 | 网页模板 | 学 院 | 源 码 | 书 籍 | 壁 纸 | 字 体 | JS脚本 | FLASH源码 | 软 件 | 矢 量 | 服务器软件 | 素 材 | 其 它 | 测试 |
设为主页
加入收藏
联系站长
平面设计 | 网页制作 | 程序编写 | 数 据 库 | 媒体动画 | 网络冲浪 | 服务器相关 | 站长乐园 | 业界动态 |
当前在线
asp获取表结构
2008-9-20 11:34:11  作者:模板天下收集整理  来源:未知 网友评论 0 条 论坛
  

asp获取表结构,并返回特定结果只写了很简单的数据类型,对于更多的数据类型,请更改代码

只写了很简单的数据类型,对于更多的数据类型,请更改代码
<%
        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

共分1页  [1] 

>> 相关文章

关于网站 | 客服中心 | 服务条款 | 合作伙伴 | 广告联系 | 本站历程 | 网站导航 | 发布资源 == 好的资源 大家共享

吉ICP备05000107号