如何使用CLASSIC ASP获取excel中的sql表结果 [英] how to fetch sql table result in excel using CLASSIC ASP
本文介绍了如何使用CLASSIC ASP获取excel中的sql表结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<%
Response.Buffer=TRUE
ON ERROR RESUME NEXT
dim conn,rs
set conn=Server.CreateObject("ADODB.Connection")
conn.connectionstring="Provider=SQLOLEDB.1;Data Source=MANIADSBHI-PC\SQLEXPRESS;Initial Catalog=master;UID=sa;Password=picme123;"
conn.Open
response.write err.number &" 1- " &err.description
IF Err.Number<>0 THEN
err_flag=true
err_msg=err_msg+"<br><H2>Connection Error, Report can not be Generated</H2>"
Err.Clear
END IF
set rs = Server.CreateObject("ADODB.recordset")
rs.MaxRecords=20
str="SELECT * FROM Persons"
set rs=conn.execute(str)
response.write err.number &" Rs - " &err.description &"<br>"
if rs.EOF then
Response.Write("No Records available")
else
do while not rs.EOF
response.Write("Person Details:") & rs("PersonId") &"-" &rs("LastName") &"-" &rs("FirstName") &"-" &rs("Address") &"-" &rs("City") &"<br>"
rs.MoveNext
loop
End if
%>
</body>
</html>
那是我的模型asp页面...任何人帮我以excel格式获取表格详细信息
That is my model asp page... Any one help me fetch the table details in excel format
推荐答案
看看这里:将SQL数据绑定到转发器控件 [ ^ ]
有一个完整的指南如何连接到SQL数据库,将数据绑定到Repeater Control并以Excel格式显示;)
Have a look here: Binding SQL Data to a Repeater Control[^]
There is a complete guide how to connect to SQL database, bind data to Repeater Control and display in Excel format ;)
这篇关于如何使用CLASSIC ASP获取excel中的sql表结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文