asp中连接SQL Server的两种方法:
1,使用ODBC
1)配置ODBC连接:控制面板->管理工具->datasource(ODBC)双击打开
之后一路下一步。
2)建立好ODBC数据源后,在ASP中如下连接:
<html>
<body>
<%
Dim conn
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "DSN=BUTSU;UID=sa;PWD=test;"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT * FROM DFAA07ST01", conn
do until rs.EOF
Response.Write("i")
Response.Write("<br />")
rs.MoveNext
loop
rs.close
conn.close
%>
</body>
</html>
2 方法二
<html>
<body>
<%
Dim conn
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "Driver={SQL Server};Server=170.10.18.19\BUTSU;UID=sa;PWD=test;DataBase=DFS"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT * FROM DFAA07ST01", conn
do until rs.EOF
Response.Write("i")
Response.Write("<br />")
rs.MoveNext
loop
rs.close
conn.close
%>
</body>
</html>