例子很明了,一看就明白。代码如下:
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数据库,其他数据库修改连接字符串。
cn.Open " Provider=SQLNCLI10;Server=(local);Database=数据库名称;Uid=数据库登录名;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
% >
' ************ 定义常量 *******************
' ---- 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数据库,其他数据库修改连接字符串。
cn.Open " Provider=SQLNCLI10;Server=(local);Database=数据库名称;Uid=数据库登录名;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数据库,其他数据库修改连接字符串。
cn.Open " Provider=SQLNCLI10;Server=(local);Database=数据库名称;Uid=数据库登录名;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
Set cmd = Server.CreateObject( " ADODB.Command " )
Set cn = Server.CreateObject( " ADODB.Connection " )
' 此处连接的是SQL Server 2008数据库,其他数据库修改连接字符串。
cn.Open " Provider=SQLNCLI10;Server=(local);Database=数据库名称;Uid=数据库登录名;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