ASP(VBSCRTP)用ADODB調用SQL預存程序

來源:互聯網
上載者:User

ASP(VBSCRTP)用ADODB調用SQL預存程序樣本

Set Cmd = Server.Createobject("ADODB.Command")                '建立對象
Cmd.ActiveConnection = Conn                                   '資料庫連結connection對象
Cmd.CommandText = "預存程序名稱"                              '要調用的預存程序名稱
Cmd.CommandType = 4                                           '設定command為調用預存程序方式
Cmd.Parameters.Append Cmd.CreateParameter("@Pid",200,1,30)    '添加聲明變數
Cmd.Parameters("@Pid") = Pid                                  '設定聲明變數的值
Set Rs = Cmd.Execute                                          '執行返回

 

CommandType:

CommandType = 1 (Recordsource由命令文本產生,通常使用SQL)

CommandType = 2 (Recordsource由為單個表名)

CommandType = 4 (Recordsource由預存程序產生)

CommandType = 8 (產生Recordsource命令類型未知,通常使用SQL)

 

CreateParameter("參數名稱",類型,方向,大小)

參數值的類型:
名稱值                     整數值                    功能
adDBTimeStamp              135                       日期時間資料類型
adDecimal                  14                        十進位整數值
adDouble                   5                         雙精確度小數值
adError                    10                        系統錯誤資訊
AdGUID                     72                        全域性唯一識別字(Globally unique identifier)
adDispath                  9                         COM/OLE自動對象(Automation Object)
adInteger                  3                         4位元組有符號整數
adIUnknown                 13                        COM/OLE對象
adLongVarBinary            205                       大型2位元組值
adLongVarChar              201                       大型字串值
adLongVarWChar             203                       大型未編碼字串
adNumeric                  131                       十進位整數值
adSingle                   4                         單精確度浮點小數
adSmallInt                 2                         2位元組有符號整數
adTinyInt                  16                        1位元組有符號整數
adUnsignedBigInt           21                        8位元組不帶正負號的整數
adUnsignedInt              19                        4位元組不帶正負號的整數
adUnsignedSmallInt         18                        2位元組不帶正負號的整數
adUnsignedTinyInt          17                        1位元組不帶正負號的整數
adUserDefined              132                       使用者自訂資料類型
adVariant                  12                        OLE對象
adVarBinary                204                       雙位元組字元變數值
adVarChar                  200                       字元變數值
advarchar                  202                       未編碼字串變數值
adWchar                    130                       未編碼字串

 

參數值的方向值:
名稱值                     整數值                    功能
adParamInput               1                         允許資料輸入至該參數當中
adParamOutput              2                         允許資料輸出至該參數當中
adParamInputOutput         3                         允許資料輸入、輸出至該參數當中
adparamReturnValue         4                         允許從一子程式中返回資料至該參數當中

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.