A simpler use of the Asp+rds client-side Reference report first
This article hopes to enter the essence
Next post a more complicated
Note: (If you are prompted that an ActiveX component cannot participate in RDS.) DataSpace)
IE need to set security options
Action: Menu Tool->internet option-> security-> Customization
Set start but ActiveX not labeled Security-> Open
<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" >
<body bgcolor=skyblue topmargin=5 leftmargin= "oncontextmenu=" return false rightmargin=0 bottommargin= "0" >
<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 * out of 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><tr><td> "+ Rs. GetString (,, "</td><td>", "</td></tr><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 and 2000
Do as 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
' Xlsheet1.range ("A3"). CopyFromRecordset RS
' xlSheet1.Application.Visible = True
End If
End Sub
</script>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service