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
%>
...全文
78 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
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>

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧