set rs=serverCreateObject("adodbrecordset")
rsopen "select top 2 from 表 order by id
",conn,1,3
if not rseof then
rsmovenext
if not rseof then
responsewrite rs("") //打印出来
rs("")= //重新赋值
rsupdate //更新
end if
end if
rsclose
<%
set rs=connopenschema(20)
do until rseof
if rs(3)="TABLE" then
responseWrite("表名:"&rs(2)&"<Br/>")
sql="select from "&rs(2)
set rs1=connexecute(sql)
responseWrite("字段名:")
for i=0 to rs1fieldscount-1
responseWrite rs1fields(i)name&" "
next
responseWrite("<BR>")
'下面的这段是字段值
'do while not rs1eof
' responseWrite " "
' for i=0 to rs1fieldscount-1
' t=rs1fields(i)name
' responseWrite rs1(t)&" "
' next
' responseWrite("<BR>")
' rs1movenext
' loop
end if
rsmovenext
loop
Set rs=Nothing
Set conn=nothing
%>
<%
SET Conn=ServerCreateObject("ADODBConnection")
Dim i,j,Sql
Set rt=ServerCreateObject("ADODBRecordset")
'ConnOpen "Server=IP地址;Provider=sqloledb;Database=库名称;UID=用户名;PWD=密码;"
ConnOpen "Server=19216811;Provider=sqloledb;Database=mysql;UID=sa;PWD=mysql;"
%>
<table bordercolor="#808000" border="1" cellspacing="0" bgcolor="#EEEEEE">
<%' 读SqlServer库中的表名:
Set rs=ConnOpenSchema(20)
While not rsEOF
if rs(3)="TABLE" then
'responsewrite(rs(2)&"<br>")'表的类型
'ResponseWrite("所在数据库名:" & rs(0) )
'ResponseWrite("所有者:" & rs(1) )
'ResponseWrite("表 名:" & rs(2) &"<br>" )
%>
<tr>
<td><%=rs(2)%></td>
<%
'这样,知道表名了,现在再来看看怎么对表的字段进行 *** 作。假设:其中数据库中有表:[admin] 获取该表的所有字段名:
x="[admin]"
rtopen"select from "&rs(2)&" where 1<>1",conn,1,3
j=rtFieldscount
For i=0 to (j-1)
'ResponseWrite("第" & i+1 & "个字段名:" & rtFields(i)Name & "<br><br>")
responsewrite("<td>"&rt(i)name)
Next
rtclose
end if
rsMoveNext
Wend
%>
</table>
分类: 电脑/网络 >> 程序设计 >> 其他编程语言
问题描述:
我做了注册表单如下
第一页是选择用户名 文本字段名称name 提交到regcheck
regcheck的代码
<%if request("name")="" then
responsewrite"<script language=JavaScript>{windowalert('对不起,请您输入需要注册的用户名!');windowlocationhref='reg2';}</script>"
end if%>
<%if len(request("name"))>12 or len(request("name"))<5 then
responsewrite"<script language=JavaScript>{windowalert('对不起,您的用户名长度不符合规则!');windowlocationhref='reg2';}</script>"
end if%>
<!--#include file="conn" -->
<head>
<STYLE type=text/css>
TD {
FONT-SIZE: 12px; COLOR: #000000;font-family: "宋体"
}
</STYLE>
</head>
<body bgcolor="#F7FCFF">
<%
name=request("name")
set rs=servercreateobject("adodbrecordset")
sql="select from user where name='"&name&"'"
rsopen sql,conn,1,3
%>
<% if not rseof then
%>
<table>
<tr>
<td>
<% ResponseWrite"<script language=JavaScript>{windowalert('对不起,这个用户已经被注册!请重新选择用户名.');windowlocationhref='reg2';}</script>"%>
<%else%>
<%session("login")=true
responsewrite"<script language=JavaScript>{windowalert('恭喜您!您选择的帐号完全可以注册,请继续填写详细资料!');windowlocationhref='reg3';}</script>"%>
<%end if%>
</td>
</tr>
</table>
</body>
<%
rsclose
set rs=nothing
connclose
set conn=nothing
%>
在第三页填写详细资料的时候,我想直接显示用户填写的用户名,而不再次填写,我用了<%=session("name")%> 为什么什么都不显示啊 也没有出错信息,在用户名后面 依然是空的 我该怎么做啊
解析:
利用session把这个用户名暂时储存起来,
session("name")="注册的用户名"
后面用到的时候就方便多了
在文本框里显示就这样写
<input type=text name=username value="<%=session("name")%>" readonly >
显示出来的用户名是不允许修改的所以要记得写上readonly(只读)
1。只是获得>
<%
Set Conn = serverCreateObject("ADODBConnection")
ConnString = "provider=microsoftjetoledb40;data source="
Connopen ConnString & ServerMapPath("DataBase/Newsdskjfhsmdb")
%>
<%
Set rs1 = ServerCreateObject("ADODBRecordset")
rs1open "select from tType",conn,1,1
for i = 0 to rs1RecordCount - 1
%>
<table width="100%" border="0" cellspacing="1">
<tr>
<td height="25" bgcolor="#00CCFF" class="f1"><%=rs1("TypeName")%> <a href="Moreasptype=<%=rs1("typeid")%>" class="A">更多……</a></td>
</tr>
<tr>
<td height="117" valign="top">
<%
Set rs2 = ServerCreateObject("ADODBRecordset")
Sql = "select top 8 from tNews where NewsTypeID=" & rs1("TypeID") & " order by NewsDate desc"
rs2open Sql,Conn,1,1
if rs2eof and rs2bof then
ResponseWrite("该版块暂无新闻")
else
do while not rs2eof
%> <a href="ShowaspNewsID=<%=rs2("Newsid")%>" class="B"><%=rs2("Newstitle")%></a><span class="f2">[<%=rs2("Newsdate")%>]</span><br>
<%rs2movenext
Loop
end if
%>
</td>
</tr>
</table>
<% rs1movenext
next
%>
<%
Set conn = nothing
Set rs1 = nothing
Set rs2 = nothing
%>
你要是告诉我你的EMAIL ,我给你发到邮箱源码(在学校做的,呵呵)
以上就是关于asp读取数据 大家帮帮我啊全部的内容,包括:asp读取数据 大家帮帮我啊、如何用asp读取表结构、asp中如何读取sqlserver数据库中的数据等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)