我想從2008年vb.net執行一個SQL Server存儲過程,但我得到的錯誤調用SQL Server存儲過程2008錯誤
過程或函數「Sp_Messages_Display」需要參數「 @MsgSno',它沒有提供。
這裏是我的代碼
Public Function Load(ByVal CnnStr As String, ByVal MsgSno As Long, ByVal Msg_Status As eMsgStatus) As ADODB.Recordset
Dim Cnn As ADODB.Connection
Dim Com As ADODB.Command
Cnn = New ADODB.Connection
Cnn.CursorLocation = ADODB.CursorLocationEnum.adUseClient
Cnn.ConnectionString = CnnStr
Cnn.Open()
Com = New ADODB.Command
Com.ActiveConnection = Cnn
With Com
.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
.CommandText = "Sp_Messages_Display"
.CreateParameter("@MsgSno", ADODB.DataTypeEnum.adBigInt, ADODB.ParameterDirectionEnum.adParamInput, 4, MsgSno)
.CreateParameter("@Msg_Status", ADODB.DataTypeEnum.adSmallInt, ADODB.ParameterDirectionEnum.adParamInput, 4, Msg_Status)
Load = .Execute(RecordsAffected)
SqlError = Err.Description
End With
If Not Load.EOF Then
With Me
.MsgSno = Load.Fields("MsgSno").Value
End With
End If
Com.ActiveConnection = Nothing
Cnn = Nothing
End Function
請幫我在哪裏,我錯了。在此先感謝
旁註:你應該** **不使用'sp_'前綴爲您的ST直接程序。微軟已經保留了這個前綴以供自己使用(參見*命名存儲過程*)](http://msdn.microsoft.com/en-us/library/ms190669%28v=sql.105%29.aspx),以及你將來有可能冒着名字衝突的風險。 [這對你的存儲過程性能也是不利的](http://www.sqlperformance.com/2012/10/t-sql-queries/sp_prefix)。最好只是簡單地避免使用'sp_'並將其他內容用作前綴 - 或者根本沒有前綴! –
您已將此標籤標記爲VB.NET:您最好使用ADO.NET而不是傳統的ADO類型。 – Richard