asp 如何连接Sqlserver 2000或 Assces?(100分)(100分)

  • 主题发起人 主题发起人 n@p
  • 开始时间 开始时间
N

n@p

Unregistered / Unconfirmed
GUEST, unregistred user!
  在Dreamweaver UltraDev用ADO连接Sqlserver 2000或 Assces,后运行在一个表里显示记录内容.代码如何写?帮帮我把代码贴出来吧,我崩溃了.
  另ASP的开发工具MS interdev哪里有下载?
  


 
作者?: 刀剑如梦
标题?: ASP访问Access数据库
关键字: Access数据库
分类?: 开发技巧
密级?: 公开
(评分: , 回复: 0, 阅读: 156) »»
ASP访问Access数据库
ASP与ACCESS数据库进行连接,代码如下:
<%@ LANGUAGE = "VBScript" %>
<!--#include file="ADOVBS.INC"-->
<%
Set objConnection = Server.CreateObject ("ADODB.Connection")
DBPath = Server.MapPath ("db1.mdb")
objConnection.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" &amp;
DBPath
SQLQuery = "SELECT * FROM Author"
Set rsRecordset = Server.CreateObject ("ADODB.Recordset")
rsRecordset.Open SQLQuery,objConnection, adOpenKeyset, adLockReadOnly
%>
<%Do Until rsRecordset.EOF %>
<tr>
<td bgcolor="f7efde" align=center>
<%= rsRecordset ("Name") %>
<br>
<%= rsRecordset ("Age") %>
<br>
</td>
</tr>
<%
rsRecordset.MoveNext
Loop
%>
<% objConnection.close %>
 
ASP的开发工具MS interdev 我正下载,第1问吧,100分
 
<%
sub showonepage(rs)
response.Write("<center><table border=1 width=575>")
response.Write("<tr bgcolor=pink>")
for i = 1 to rs.Fields.Count-1
response.Write("<td width=144>" &amp;
rs.fields(i).name &amp;
"</td>")
next
response.Write("</tr>")
rs.AbsolutePage = page
for iPage = 1 to rs.RecordCount
response.Write("<tr>")
for i = 1 to rs.Fields.Count-1
response.Write ("<td>" &amp;
rs.fields(i).Value &amp;
"</td>")
next
response.Write("</tr>")
rs.MoveNext
if rs.EOF then
exit for
end if
next
response.Write("</table></center>")
end sub
dim rs,exec,conn
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&amp;server.mappath("data/data.mdb")
exec="select * from message"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,3
%>
<html>
<!--#include file=onepage.asp -->
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">
</head>
<body>
<!--#include file=top.asp -->
<table width="775" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100" height="404" align="center" valign="top" bgcolor=#ffcf60>
</td>
<td width="575" height="404" align="center" valign="top">
<br>
<strong><font color=#808000 size=4>留言记录</font></strong>
<br><br>
<% if rs.RecordCount = 0 then
%>
<script language="vbscript">
MsgBox"暂时没有留言",48,"confirm"
</script>
<% else

showonepage rs
end if
%>
</td>
<td width="100" height="404" align="center" valign="top" bgcolor=#ffcf60>
</td>
</tr>
<!--#include file=end.
asp -->
<p>&amp;nbsp;
</p>
</body>
</html>
 
TO app2001 和zzb1984:在Dreamweaver UltraDev运行表可以显示吗?我现在用别人电脑,不能试.
 
TO app2001 :ADOVBS.INC什么?
 
一、下段是Access数据库读写,比较节省系统资源,同时可重复作用
Set Conn = Server.CreateObject("ADODB.Connection")
DataName = Server.MapPath("Sample.mdb")
Conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ="&amp;
DataName
Set Rs = Conn.Execute("Select * From w1")
二、下段是SQL Server数据库连接,最后两句更改(如上:)
Params = "Provider = SQLOLEDB.1;Server Name=127.0.0.1"
Params = Params &amp;";User ID=sa;Password=;Database=Sample"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Params
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open "Select * From folder",Conn,3,2
三、 用DSN连接
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.ActiveConnection ="dsn=LocalServer;uid=sa;pwd=sa2002;"
Rs.Source = "SELECT * FROM Table1"
Rs.Open
 
在在Dreamweaver UltraDev运行怎么没有显示表的数据?
 
用DSN连接时出错!为何呢??
用SQL Server连接正常。
DSN设置连接亦正常。测试完全成功!
 
没有注意IIS,接受答案.25分/人
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部