<%@ Language = VBScript %> <%Option Explicit%> <html> <head> <title>List</title> <meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"> <% dim conn dim rs dim sql dim aa set conn = server.CreateObject ("adodb.connection") conn.open "Driver={SQL Server};Description=;SERVER=gq;UID=sa;PWD=;DATABASE=test;"sql = "select tt,bb from district order by locationid asc" set rs = conn.execute(sql) if not rs.eof then aa=rs("tt") '第一条数据 。 end if rs.movenext ‘下一条数据 。rs.close conn.close set rs=nothing set conn=nothing %>
最好是使用oledb方式,连接数据库如下: <% Dim Conn,Rs Set Conn=Server.CreateObject("ADODB.Connection") Set Rs=Server.CreateObject("ADODB.Recordset") Conn.Open "provider=sqloledb;data source=SqlServerName;initial catalog=DBName;user id=sa;" %>
就要一个asp访问、操作sql server的简单小程序就行了
例如用asp如何连接sql server拉 怎么发送查询拉 怎么输出返回的查询等等的...
谢谢各位 一定给分
<%Option Explicit%>
<html>
<head>
<title>List</title>
<meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<%
dim conn
dim rs
dim sql
dim aa
set conn = server.CreateObject ("adodb.connection")
conn.open "Driver={SQL Server};Description=;SERVER=gq;UID=sa;PWD=;DATABASE=test;"sql = "select tt,bb from district order by locationid asc"
set rs = conn.execute(sql)
if not rs.eof then
aa=rs("tt") '第一条数据
。
end if
rs.movenext ‘下一条数据
。rs.close
conn.close
set rs=nothing
set conn=nothing
%>
<%
Dim Conn,Rs
Set Conn=Server.CreateObject("ADODB.Connection")
Set Rs=Server.CreateObject("ADODB.Recordset")
Conn.Open "provider=sqloledb;data source=SqlServerName;initial catalog=DBName;user id=sa;"
%>