我用的数据库是SQL server 2005 开发版 登入时windows 模式进入 登入名是PC-200905152140 无密码 里面有个Factoryx 的数据库 表个workerx 里面含有sno sname 等等列下面是我的ASP 代码
<HTML>
<HEAD>
<TITLE>sqlservertablelist.asp</TITLE>
</HEAD>
<body bgcolor="#FFFFFF"><%
whichDSN="DSN=pubs;User ID=PC-200905152140"
'调用一个函数
call query2table("select * from authors where au_lname='White'", whichDSN)
%><!--#include file="lib_dbtable.asp"--></BODY>
</HTML>lib_dbtable.asp文件内容如下:
<%
sub query2table(inputquery, inputDSN)
dim conntemp, rstemp set conntemp=server.createobject("adodb.connection")
conntemp.open inputDSN
set rstemp=conntemp.execute(inputquery)
howmanyfields=rstemp.fields.count-1
%>
<table border=1><tr>
<%
'先输出字段名
for i=0 to howmanyfields
%>
<td><b><%=rstemp(i).name%></B> </td>
<% next %>
</tr>
<%
'现在取出所有数据
do while not rstemp.eof
%>
<tr><%
for i = 0 to howmanyfields '显示所有字段名称
thisvalue=rstemp(i)
If isnull(thisvalue) then
thisvalue=" "
end if
%>
<td valign=top><%=thisvalue%> </td>
<% next %>
</tr><%
rstemp.movenext'显示下一个字段
loop
%>
</table>
<%
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
end sub
%>
因为是第一次 用数据库 和ASP 哪位高手能指点一下 万分感激 急!
<HTML>
<HEAD>
<TITLE>sqlservertablelist.asp</TITLE>
</HEAD>
<body bgcolor="#FFFFFF"><%
whichDSN="DSN=pubs;User ID=PC-200905152140"
'调用一个函数
call query2table("select * from authors where au_lname='White'", whichDSN)
%><!--#include file="lib_dbtable.asp"--></BODY>
</HTML>lib_dbtable.asp文件内容如下:
<%
sub query2table(inputquery, inputDSN)
dim conntemp, rstemp set conntemp=server.createobject("adodb.connection")
conntemp.open inputDSN
set rstemp=conntemp.execute(inputquery)
howmanyfields=rstemp.fields.count-1
%>
<table border=1><tr>
<%
'先输出字段名
for i=0 to howmanyfields
%>
<td><b><%=rstemp(i).name%></B> </td>
<% next %>
</tr>
<%
'现在取出所有数据
do while not rstemp.eof
%>
<tr><%
for i = 0 to howmanyfields '显示所有字段名称
thisvalue=rstemp(i)
If isnull(thisvalue) then
thisvalue=" "
end if
%>
<td valign=top><%=thisvalue%> </td>
<% next %>
</tr><%
rstemp.movenext'显示下一个字段
loop
%>
</table>
<%
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
end sub
%>
因为是第一次 用数据库 和ASP 哪位高手能指点一下 万分感激 急!
这个是 要打开数据库的 那段信息 你看看DSN有没有问题吧
3楼 我建一个 带密码 的登入模式 难道要重装SQL 能说清楚点吗