|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
写软件都是想的时间比写的时间要长的.如果反过来了就得看看是什么原因了.另外大家可以回去问问公司里的小MM.(一般企业里,跟你们交付软件接触得最多的是她们)初级|客户端上回曾贴一篇较复杂的用ASP+RDS客户端参生报表
此回贴一篇较庞大的用ASP+RDS+组件客户端参生报表
毛病申明:(若提醒ActiveX元件没法参生RDS.DataSpace)
IE需设置平安选项
操纵:菜单工具->INTERNET选项->平安性->自界说
设置:肇端但ActiveX不标示为平安->开启
道理申明:
客户端间接用RDS发生RecordSet平安性不敷,利用了
middle-tierAutomationcomponents后可年夜年夜增添平安性!
请看下文:
编写注册元件:
ActiveXDllproject:iacrdsobj.vbp
ClassModulename:RsOp
PublicFunctionReturnRs(strDBAsVariant,strSQLAsVariant)AsADODB.Recordset
ReturnsanADODBrecordset.
OnErrorGoToehGetRecordset
DimcnAsNewADODB.Connection
DimrsAsNewADODB.Recordset
DimstrConnectAsString
strConnect="Provider=SQLOLEDB;Server=servername;uid=sa;pwd=;Database="&strDB&";"
cn.OpenstrConnect
Thesearenotlistedinthetypelib.
rs.CursorLocation=adUseClient
UsingtheUnspecifiedparameters,anADO/Rrecordsetisreturned.
rs.OpenstrSQL,cn,adOpenUnspecified,adLockUnspecified,adCmdUnspecified
SetReturnRs=rs
ExitFunction
ehGetRecordset:
Err.RaiseErr.Number,Err.Source,Err.Description
EndFunction
然后MAKEiacrdsobj.dll
如有错,请设置VB菜单PROJECT-REFREENCE
增添MicroSoftActiveXDataObject2.6Library(固然数字要高一点)
然后注册iacrdsobj.dll到数据库server(为平安,最好变动数据库uid最好不为sa)!
好,接上去看asp
long1.asp
<html>
<head>
<METAcontent="text/html;charset=gb2312"http-equiv=Content-Type>
<title>clientuserdsproduceexcelreport</title>
</head>
<bodybgColor=skybluetopMargin=5leftMargin="20"oncontextmenu="returnfalse"rightMargin=0bottomMargin="0">
<divalign="center"><center>
<tableborder="1"bgcolor="#ffe4b5"style="HEIGHT:1px;TOP:0px"bordercolor="#0000ff">
<tr>
<tdalign="middle"bgcolor="#ffffff"bordercolor="#000080">
<fontcolor="#000080"size="3">
clientuserdsproduceexcelreport
</font>
</td>
</tr>
</table>
</div>
<formaction="long1.asp"method="post"name="myform">
<DIValign=left>
<inputtype="button"value="QueryData"name="query"language="vbscript"onclick="fun_excel(1)"style="HEIGHT:32px;WIDTH:90px">
<inputtype="button"value="ClearData"name="Clear"language="vbscript"onclick="fun_excel(2)"style="HEIGHT:32px;WIDTH:90px">
<inputtype="button"value="ExcelReport"name="report"language="vbscript"onclick="fun_excel(3)"style="HEIGHT:32px;WIDTH:90px">
</div>
<DIVid="adddata"></div>
</form>
</body>
</html>
<scriptlanguage="vbscript">
subfun_excel(t)
Dimrds,rs,df,ServerStr
dimstrSQL,StrRs
DimxlApp,xlBook,xlSheet1
ServerStr="http://SqlServerName"thesqlservernameofregisteriacRDSObj.dll
userdstoproduceclientrecordset
setrds=CreateObject("RDS.DataSpace",ServerStr)
eg:setrds=CreateObject("RDS.DataSpace","http://iac_fa")iac_faistheLANsqlservername
eg:setrds=CreateObject("RDS.DataSpace","http://10.150.254.102")10.150.254.102istheLANsqlserverIPAddress
theregistercom
Setdf=rds.CreateObject("iacRDSObj.rsop",ServerStr)
thequerystringofsql
strSQL="Selecttop8*fromjobsorderbyjob_id"
therecordset
Setrs=df.ReturnRs("pubs",strSQL)
ift=1then
ifnotrs.eofthen
StrRs="<tableborder=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"Nodatainthetable!"
endif
elseift=2then
StrRs=""
adddata.innerHTML=StrRs
elseift=3then
SetxlApp=CreateObject("EXCEL.APPLICATION")
SetxlBook=xlApp.Workbooks.Add
SetxlSheet1=xlBook.Worksheets(1)
xl</p>asp可以轻松地实现对页面内容的动态控制,根据不同的浏览者,显示不同的页面内容。而浏览者一点觉察不出来,就像为他专门制作的页面一样。使用各种各样的组件,asp可以完成无比强大的功能。 |
|