I am trying to use th EntLib DAAB to execute a sp that inserts some values and reutrns two output parameters (returned as an array) . I pretty much modified the function in the documentation to fit my need, but I get the Object must implement IConvertible. This is getting pretty frustrating because according to the example it should work. Any and all help is appreciated.
Object must implement IConvertible.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Object must implement IConvertible.
Source Error:
Line 28: dbCommandWrapper.AddOutParameter("@supplement_no", DbType.Int16, 4)
Line 29:
Line 30: db.ExecuteNonQuery(dbCommandWrapper)
Line 31:
Line 32: ' Row of data is captured via output parameters
|
Source File: c:\inetpub\wwwroot\CaseMgmt\Classes\DataAccess.vb Line: 30
sdsd
Stack Trace:
[InvalidCastException: Object must implement IConvertible.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
Microsoft.Practices.EnterpriseLibrary.Data.Database.DoExecuteNonQuery(DBCommandWrapper command)
Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteNonQuery(DBCommandWrapper command)
CaseMgmt.CaseMgmt.DataAccess.NewSLCaseInsert(Int32& CaseType, Int32& SubCaseType, String& UserName, Int32& CompanyCode, Int32& Loc) in c:\inetpub\wwwroot\CaseMgmt\Classes\DataAccess.vb:30
CaseMgmt.CaseMgmt.SLQuickStart.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\CaseMgmt\SLQuickStart.aspx.vb:54
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
|
And here is the function being executed:
<code>
Public
Function NewSLCaseInsert(ByRef CaseType As Integer, ByRef SubCaseType As Integer, ByRef UserName As String, ByRef CompanyCode As Integer, ByRef Loc As Integer) As ArrayList
Dim DateNow As DateTime = DateNow.Now
Dim TimeNow As TimeSpan = DateNow.TimeOfDay
' Create the Database object, using the default database service. The
' default database service is determined through configuration.
Dim db As Database = DatabaseFactory.CreateDatabase()
'Dim sqlCommand As String = "LP_CASE_NEW_CASE"
Dim dbCommandWrapper As DBCommandWrapper = db.GetStoredProcCommandWrapper("LP_CASE_NEW_CASE")
' Add paramters
' Input parameters can specify the input value
dbCommandWrapper.Command.CommandType = CommandType.StoredProcedure
dbCommandWrapper.AddInParameter("@user", DbType.String, UserName)
dbCommandWrapper.AddInParameter("@co", DbType.Int16, CompanyCode)
dbCommandWrapper.AddInParameter("@loc", DbType.Int16, Loc)
dbCommandWrapper.AddInParameter("@date", DbType.Date, DateNow.Date)
dbCommandWrapper.AddInParameter("@time", DbType.Time, DateNow.TimeOfDay)
dbCommandWrapper.AddInParameter("@case_type_cd", DbType.Int16, CaseType)
dbCommandWrapper.AddInParameter("@sub_case_type_cd", DbType.Int16, SubCaseType)
' Output parameters specify the size of the return data
dbCommandWrapper.AddOutParameter("@CASE_ID", DbType.Int16, 4)
dbCommandWrapper.AddOutParameter("@supplement_no", DbType.Int16, 4)
db.ExecuteNonQuery(dbCommandWrapper)
' Row of data is captured via output parameters
Dim CaseId As Integer = dbCommandWrapper.GetParameterValue("@CASE_ID")
Dim SupplNum As Integer = dbCommandWrapper.GetParameterValue("@supplement_no")
Dim arrReturn As ArrayList
arrReturn.Add(CaseId)
arrReturn.Add(SupplNum)
Return arrReturn
End Function</code>