-1
我以前曾問過類似的問題,雖然我試圖解決我以前的代碼,但現在我得到了一個錯誤「參數是錯誤的類型,超出了可接受的範圍,或相互衝突「。我想傳遞一個字符作爲參數來查詢數據庫,然後使用記錄集打印出一個網頁。我的經典ASP代碼低於傳遞參數到存儲過程中經典的asp
Set objCon = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")
set objComm = CreateObject("ADODB.Command")
objCon.ConnectionString = "Provider=SQLOLEDB.1;Password=xxxx;Persist Security Info=True;User ID=xxxx;Initial Catalog=Movies;Data Source=xxxx-PC"
objCon.open objCon.ConnectionString
objComm.ActiveConnection = objCon.ConnectionString
objComm.CommandText = "Paging_Movies"
objComm.CommandType = adCmdStoredProc
Set objParameter = objComm.CreateParameter
objParameter.Name = "alphaChar"
objParameter.Type = adChar
objParameter.Direction = adParamInput
objParameter.Value = "a"
objComm.Parameters.Append objParameter
set objRs = objComm.Execute
而且我的存儲過程是如下 -
CREATE PROCEDURE Paging_Movies
@alphaChar char(1)
AS
if @alphaChar = '#'
select * from Movies where movies like '[^a-z]%'
else
select * from Movies where movies like @alphaChar + '%'
不幸的是我最終的類型不匹配? – 2011-06-16 08:55:26
@ kurupt89:嘗試指定1的長度? [見本手冊頁。](http://www.w3schools.com/ado/met_comm_createparameter.asp) – Andomar 2011-06-16 09:13:19
感謝你的回覆幫助我找到答案。我不得不將adChar和adParamInput更改爲數字表示形式 – 2011-06-16 09:16:58