asp小问题~~~

xiexieoooooo 2010-07-16 08:15:21
1.表(图)

2.就想在本页用response.write ..输出数据库里的内容
3.连接数据库就用这样的`~
<%
'创建Connection对象
Set conn =Server.CreateObject("Adodb.Connection")
'设置驱动
tmpPD="Provider=Microsoft.Jet.OLEDB.4.0"
'指定数据库的路径
tmpDS="Data Source="&Server.MapPath("counter.mdb")
'指定数据库的密码
tmpPW="Jet OLEDB:Database Password=123"
'构造打开字符串
tmpSTR=tmpPD&";"&tmpDS&";"&tmpPW
'利用Connection对象的Open方法打开数据库
conn.Open tmpSTR
'建立库连接
Set rs = Server.CreateObject("Adodb.Recordset")

.
.
.
.
.
'利用Connection对象的Close方法关闭连接
rs.Close
'将Connection对象从内存中删除,以释放资源
Set rs = Nothing
Set conn = Nothing
%>
...全文
62 点赞 收藏 6
写回复
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangcookie 2010-07-17
<%
...
Set rs = Server.CreateObject("Adodb.Recordset")
sql=""SELECT * FROM myCount""
rs.Open sql, conn, 1, 1
Do While Not rs.EOF
str=str&rs(0)&","&rs(1)&"|"
rs.MoveNext
Loop
rs.Close
str=left(str,len(str)-1)
response.write str
conn.Close
Set rs = Nothing
Set conn = Nothing
%>
回复
叫我梁大侠 2010-07-17
[Quote=引用 4 楼 chinmo 的回复:]
VBScript code
<%
...
Set rs = Server.CreateObject("Adodb.Recordset")
rs.CursorLocation = 1
rs.Open "SELECT * FROM myCount", conn, 1, 1
Do While Not rs.EOF
str=str&rs(0)&","&rs(1)&am……
[/Quote]
同意
回复
<%
...
Set rs = Server.CreateObject("Adodb.Recordset")
rs.CursorLocation = 1
rs.Open "SELECT * FROM myCount", conn, 1, 1
Do While Not rs.EOF
str=str&rs(0)&","&rs(1)&"|"
rs.MoveNext
Loop
rs.Close
str=left(str,len(str)-1)
response.write str
conn.Close
Set rs = Nothing
Set conn = Nothing
%>
回复
scscms太阳光 2010-07-16
where 编号=1 就是条件,1可以改成其他数字
<%
...
Set rs = Server.CreateObject("Adodb.Recordset")
sql="select count from mycount where 编号=1"
rs.Open sql,conn, 1, 1
if Not rs.EOF
Response.write rs(0)
else
Response.write "没有查到数据"
end if
rs.Close
conn.Close
Set rs = Nothing
%>
回复
xiexieoooooo 2010-07-16
hookee~~
my old friend~~~
可以用一个变量引出数据库字段的直吗~~
因为我要把这个变量传到flash里面~~
谢谢~~
回复
hookee 2010-07-16

<table>
<%
...
Set rs = Server.CreateObject("Adodb.Recordset")
rs.CursorLocation = 1
rs.Open "SELECT * FROM myCount", conn, 1, 1
Do While Not rs.EOF
%>
<tr>
<td><%=rs(0)%></td><td><%=rs(1)%></td>
</tr>
<%
rs.MoveNext
Loop
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
%>
</table>
回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告