asp

位置:IT落伍者 >> asp >> 浏览文章

ASP编程进行参数化查新实例代码


发布日期:2019年02月12日
 
ASP编程进行参数化查新实例代码

<%
’************定义常量*******************
ParameterDirectionEnumValues
ConstadParamUnknown=&H
ConstadParamInput=&H
ConstadParamOutput=&H
ConstadParamInputOutput=&H
ConstadParamReturnValue=&H

CommandTypeEnumValues
ConstadCmdUnknown=&H
ConstadCmdText=&H
ConstadCmdTable=&H
ConstadCmdStoredProc=&H
ConstadCmdFile=&H
ConstadCmdTableDirect=&H

DataTypeEnumValues
ConstadEmpty=
ConstadTinyInt=
ConstadSmallInt=
ConstadInteger=
ConstadBigInt=
ConstadUnsignedTinyInt=
ConstadUnsignedSmallInt=
ConstadUnsignedInt=
ConstadUnsignedBigInt=
ConstadSingle=
ConstadDouble=
ConstadCurrency=
ConstadDecimal=
ConstadNumeric=
ConstadBoolean=
ConstadError=
ConstadUserDefined=
ConstadVariant=
ConstadIDispatch=
ConstadIUnknown=
ConstadGUID=
ConstadDate=
ConstadDBDate=
ConstadDBTime=
ConstadDBTimeStamp=
ConstadBSTR=
ConstadChar=
ConstadVarChar=
ConstadLongVarChar=
ConstadWChar=
ConstadVarWChar=
ConstadLongVarWChar=
ConstadBinary=
ConstadVarBinary=
ConstadLongVarBinary=
ConstadChapter=
ConstadFileTime=
ConstadPropVariant=
ConstadVarNumeric=
ConstadArray=&H

Dimrscmdcn
Setcmd=ServerCreateObject("ADODBCommand")
Setcn=ServerCreateObject("ADODBConnection")
’此处连接的是SQLServer数据库其他数据库修改连接字符串
cnOpen"Provider=SQLNCLI;Server=(local);Database=数据库名称;Uid=数据库登录名;Pwd=密码;"
Withcmd
ActiveConnection=cn
CommandType=adCmdText
CommandText="Select*FromBaseObjectWhereparentnameLIKE?Andcontentclass=?"
Prepared=True
ParametersAppendCreateParameter("parentname"adVarCharadParamInput"%/ItemImage/%")
ParametersAppendCreateParameter("mengxianhui"adVarCharadParamInput"urn:schemasmengxianhuicomcn:basedocument")
Setrs=Execute
EndWith
WhileNotrsEOF
ResponseWrite"<li>"&rs("displayname")
rsMoveNext
Wend
Setcmd=Nothing
Setrs=Nothing
Setcn=Nothing
%>

也可以写出下面的格式
Dimrscmdcn
Setcmd=ServerCreateObject("ADODBCommand")
Setcn=ServerCreateObject("ADODBConnection")
’此处连接的是SQLServer数据库其他数据库修改连接字符串
cnOpen"Provider=SQLNCLI;Server=(local);Database=数据库名称;Uid=数据库登录名;Pwd=密码;"
Withcmd
ActiveConnection=cn
CommandType=adCmdText
CommandText="Select*FromBaseObjectWhereparentnameLIKE?Andcontentclass=?"
Prepared=True
Parameters()Value="%/ItemImage/%"
Parameters()Value="urn:schemasmengxianhuicomcn:basedocument"
Setrs=Execute
EndWith
WhileNotrsEOF
ResponseWrite"<li>"&rs("displayname")
rsMoveNext
Wend

上一篇:asp快速分页代码

下一篇:ASP中实现分页显示的七种武器