Post a simple report on using the ASP + RDS Client
This article is intended to be excellent.
Next post a complex article
Note: (if an error occurs when an ActiveX component is prompted, the parameter RDS. DataSpace cannot be generated)
Set security options for IE
Operation: Choose menu tools> Internet Options> Security> Custom
Set start time but ActiveX is not marked as security-> enable
<HTML>
<Head>
<Meta content = "text/html; charset = gb2312" http-equiv = Content-Type>
<Title> client use RDS produce Excel report </title>
<LINK rel = "stylesheet" href = "cdutmenu/common.css">
</Head>
<Body bgcolor = skyblue topmargin = 5 leftmargin = "20" oncontextmenu = "Return false" rightmargin = 0 bottommargin = "0">
<Div align = "center"> <center>
<Table border = "1" bgcolor = "# ffe4b5" style = "height: 1px; top: 0px" bordercolor = "# 0000ff">
<Tr>
<TD align = "Middle" bgcolor = "# ffffff" bordercolor = "#000080">
<Font color = "#000080" size = "3">
Client use RDS produce Excel report
</Font>
</TD>
</Tr>
</Table>
</Div>
<Script language = "VBScript">
Sub fun_excel (t)
Dim RDS, RS, DF
Dim strcn, strsql, strrs
Dim xlapp, xlbook, xlsheet1
'Use RDS to produce client recordset
Set RDS = Createobject ("RDS. DataSpace ")
Set df = RDS. Createobject ("rdsserver. DataFactory", "http: // server; Name ")
'The connection string to SQL Server to query database: pubs ---> table: jobs
Strcn = "driver = {SQL Server}; server = server name; uid = sa; APP = Microsoft development environment; database = pubs; user id = sa; Password = ;"
'The query string of SQL
Strsql = "select Top 8 * from jobs order by job_id"
The recordset
Set rs = DF. Query (strcn, strsql)
If T = 1 then
If not Rs. EOF then
Strrs = "<Table border = 1> <tr> <TD> job_id </TD> <TD> job_desc </TD> <TD> max_lvl </TD> <TD> min_lvl </TD> </tr> <TD> "Rs. getstring (, "</TD> <TD>", "</TD> </tr> <TD> ","") "</TD> </tr> </table>"
Adddata. innerhtml = strrs
Strrs = ""
Else
Msgbox "no data in the table! "
End if
Elseif t = 2 then
Strrs = ""
Adddata. innerhtml = strrs
Elseif T = 3 then
Set xlapp = Createobject ("Excel. application ")
Set xlbook = xlapp. workbooks. Add
Set xlsheet1 = xlbook. worksheets (1)
Xlsheet1.cells (1, 1). value = "The job table"
Xlsheet1.range ("A1: d1"). Merge
Xlsheet1.cells (2, 1). value = "job_id"
Xlsheet1.cells (2, 2). value = "job_desc"
Xlsheet1.cells (2, 3). value = "max_lvl"
Xlsheet1.cells (2, 4). value = "min_lvl"
CNT = 3
'Adapt to Office 97 and 2000'
Do while not Rs. EOF
Xlsheet1.cells (CNT, 1). value = RS ("job_id ")
Xlsheet1.cells (CNT, 2). value = RS ("job_desc ")
Xlsheet1.cells (CNT, 3). value = RS ("max_lvl ")
Xlsheet1.cells (CNT, 4). value = RS ("min_lvl ")
Rs. movenext
CNT = CINT (CNT) 1
Loop
Xlsheet1.application. Visible = true
'Adapt to Office 2000 only
'Xlsheet1. Range ("A3"). copyfromrecordset rs
'Xlsheet1. application. Visible = true
End if
End sub
</SCRIPT>