在ASP頁面進(jìn)行參數(shù)化查新一例 收藏
例子很明了,,一看就明白,。代碼如下: VBScript 代碼
< % ' ************ 定義常量 ******************* ' ---- ParameterDirectionEnum Values ---- Const adParamUnknown = & H0000 Const adParamInput = & H0001 Const adParamOutput = & H0002 Const adParamInputOutput = & H0003 Const adParamReturnValue = & H0004 ' ---- CommandTypeEnum Values ----
Const adCmdUnknown = & H0008 Const adCmdText = & H0001 Const adCmdTable = & H0002 Const adCmdStoredProc = & H0004 Const adCmdFile = & H0100 Const adCmdTableDirect = & H0200 ' ---- DataTypeEnum Values ----
Const adEmpty = 0 Const adTinyInt = 16 Const adSmallInt = 2 Const adInteger = 3 Const adBigInt = 20 Const adUnsignedTinyInt = 17 Const adUnsignedSmallInt = 18 Const adUnsignedInt = 19 Const adUnsignedBigInt = 21 Const adSingle = 4 Const adDouble = 5 Const adCurrency = 6 Const adDecimal = 14 Const adNumeric = 131 Const adBoolean = 11 Const adError = 10 Const adUserDefined = 132 Const adVariant = 12 Const adIDispatch = 9 Const adIUnknown = 13 Const adGUID = 72 Const adDate = 7 Const adDBDate = 133 Const adDBTime = 134 Const adDBTimeStamp = 135 Const adBSTR = 8 Const adChar = 129 Const adVarChar = 200 Const adLongVarChar = 201 Const adWChar = 130 Const adVarWChar = 202 Const adLongVarWChar = 203 Const adBinary = 128 Const adVarBinary = 204 Const adLongVarBinary = 205 Const adChapter = 136 Const adFileTime = 64 Const adPropVariant = 138 Const adVarNumeric = 139 Const adArray = & H2000 Dim rs, cmd, cn
Set cmd = Server.CreateObject( " ADODB.Command " ) Set cn = Server.CreateObject( " ADODB.Connection " ) ' 此處連接的是SQL Server 2008數(shù)據(jù)庫,,其他數(shù)據(jù)庫修改連接字符串,。 cn.Open " Provider=SQLNCLI10;Server=(local);Database=數(shù)據(jù)庫名稱;Uid=數(shù)據(jù)庫登錄名;Pwd=密碼; " With cmd .ActiveConnection = cn .CommandType = adCmdText .CommandText = " Select * From BaseObject Where parentname LIKE ? And contentclass=? " .Prepared = True .Parameters.Append .CreateParameter( " parentname " ,adVarChar,adParamInput, 512 , " %/ItemImage/% " ) .Parameters.Append .CreateParameter( " mengxianhui " ,adVarChar,adParamInput, 512 , " urn:schemas-mengxianhui-com-cn:basedocument " ) Set rs = .Execute End With While Not rs.EOF Response.Write " <li> " & rs( " displayname " ) rs.MoveNext Wend Set cmd = Nothing Set rs = Nothing Set cn = Nothing % > 也可以寫出下面的格式: VBScript 代碼
Dim rs, cmd, cn Set cmd = Server.CreateObject( " ADODB.Command " ) Set cn = Server.CreateObject( " ADODB.Connection " ) ' 此處連接的是SQL Server 2008數(shù)據(jù)庫,,其他數(shù)據(jù)庫修改連接字符串。 cn.Open " Provider=SQLNCLI10;Server=(local);Database=數(shù)據(jù)庫名稱;Uid=數(shù)據(jù)庫登錄名;Pwd=密碼; " With cmd .ActiveConnection = cn .CommandType = adCmdText .CommandText = " Select * From BaseObject Where parentname LIKE ? And contentclass=? " .Prepared = True .Parameters( 0 ).Value = " %/ItemImage/% " .Parameters( 1 ).Value = " urn:schemas- mengxianhui -com-cn:basedocument " Set rs = .Execute End With While Not rs.EOF Response.Write " <li> " & rs( " displayname " ) rs.MoveNext Wend 本文來自CSDN博客,轉(zhuǎn)載請標(biāo)明出處:http://blog.csdn.net/net_lover/archive/2010/08/18/5821116.aspx
|
|