本实例演示利用Ajax技术,通过asp文件,从SQL Server数据库中读取数据。
1、新建一个网站。
2、在网站目录下新建一个txt文档,改名为datasource.asp,内容为:
<%@Language="vbscript" Codepage="65001"%>
<%
response.expires=-1
sql="SELECT * FROM "
sql=sql & request.querystring("q") Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB;Persist Security Info=False;User ID=sa;PWD=abc;Initial Catalog=GoodLuck;Data Source=localhost"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,connresponse.write("<table>")
do until rs.EOFfor each x in rs.Fieldsresponse.write("<tr>&l