ASP編程進行參數化查新執行個體代碼

來源:互聯網
上載者:User

< %
’ ************ 定義常量 ******************* 
’ ---- 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 
% > 

 也可以寫出下面的格式: 
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 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.