发布网友 发布时间:2024-10-24 06:25
共2个回答
热心网友 时间:2024-10-26 18:36
<%
public function OpenDB()
on error resume next
dim sConn,Conn '存放数据库联接的信息
sConn="PROVIDER=SQLOLEDB;driver={sql server};server=.;database=数据库名;uid=sa;pwd=数据库密码"
set Conn=server.CreateObject("adodb.Connection")
Conn.Open sConn
if err.number<>0 then
Response.Write "数据库连接出错!"
Response.End
else
set OpenDB=Conn
end if
end function
%>
<%
Set Conn=OpenDB()
set rs=server.createobject("adodb.recordset")
sql="select * from user"
rs.Open sql,Conn,1,1
if not rs.eof then
for i=1 to recordcount
response.write rs("company ") '输出公司
next
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
热心网友 时间:2024-10-26 18:38
set conn=server.createobject("adodb.connection")
connstr="driver=sqlserver;server=localhost;uid=root;pwd=;database=xxw_data"
conn.open connstr
set rs=server.createobject("adodb.recordset")
rs.open "select company form user",conn,1,1
do while not rs.eof
response.write rs("company")&"<br />"
rs.movenext
loop
if rs.eof then exit do