Parameterized Store Procedures Failing


Author
Message
Jeff Pagley
Jeff Pagley
Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)
Group: StrataFrame Users
Posts: 223, Visits: 893
Hi SF Team,

I have just setup ES on a server and I began to do some testing.  The code (below) has been running for a couple of years on a local production server with a SQLExpress database, but when this same code (below) runs connecting through ES, I am getting an error (see below).  This piece of code is using a BO to run a parameterized stored procedure.  I am getting the same error when running other BOs using parameterized stored procredures.  It seems this error is associated with the BO.FillByStoredProcedure method.   What is going on?

Thanks,

Jeff

Public Sub FillByCallBackTop1ByCampaignIDAndUserIDAndDateRange(ByVal campaignID As Integer, ByVal userID As Integer, _

ByVal startDate As Date, ByVal endDate As Date, ByVal campaignMaximumCallTries As Integer)

Dim parms(4) As SqlParameter

parms(0) = New SqlParameter("@CampaignID", SqlDbType.Int)

parms(0).Value = campaignID

parms(1) = New SqlParameter("@UserID", SqlDbType.Int)

parms(1).Value = userID

parms(2) = New SqlParameter("@StartDate", SqlDbType.SmallDateTime)

parms(2).Value = startDate

parms(3) = New SqlParameter("@EndDate", SqlDbType.SmallDateTime)

parms(3).Value = endDate

parms(4) = New SqlParameter("@CampaignMaximumCallTries", SqlDbType.SmallInt)

parms(4).Value = campaignMaximumCallTries

Me.FillByStoredProcedure("CampaignContactsView_CallBack_Top_ByCampaignIDUserIDStartEndDate_Select", parms)

End Sub

=========================================================================================

Exception (EnterpriseDataSourceException)

Message = "An error occurred while executing the command on the remote data source. See the inner exception for more details."

InnerException (SqlException): Source=".Net SqlClient Data Provider"; Target=null; Tag=null; Class=16; LineNumber=0; Number=201; Server="TESTSERVER\SQLEXPRESS"; State=4; ErrorCode=-2146232060;

Message = "Procedure or Function 'CampaignContactsView_CallBack_Top1_ByCampaignIDUserIDStartEndDate_Select' expects parameter '@CampaignID', which was not supplied."

StackTrace =

" at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)

at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)

at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)

at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()

at System.Data.SqlClient.SqlDataReader.get_MetaData()

at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)

at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)

at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior ... (truncated) ...xecuteReader(CommandBehavior behavior, String method)

at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)

at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)

at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)

at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)

at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)

at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)

at MicroFour.StrataFrame.Data.SqlDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)

at MicroFour.StrataFrame.Data.Enterprise.RequestProcessor.ExecuteDataTable(ExecuteDataTableParams params)"

Errors (SqlErrorCollection): Count=1;

#0 = {System.Data.SqlClient.SqlError: Procedure or Function 'CampaignContactsView_CallBack_Top1_ByCampaignIDUserIDStartEndDate_Select' expects parameter '@CampaignID', which was not supplied.}

Procedure = "CampaignContactsView_CallBack_Top1_ByCampaignIDUserIDStartEndDate_Select"

Environment: ThreadIdentity="" DateTime=["2010-01-29 07:53:48.537"] ThreadName=null WindowsIdentity="STRUSS\JPagley" ThreadId="10" DomainName="ProspectHelper.vshost.exe" OSVersion=["Microsoft Windows NT 5.1.2600 Service Pack 3"]

MachineName="1LPJPAGLEY" UserName="JPagley"


Replies
Keith Chisarik
Keith Chisarik
StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
Works fine when using ExecuteScalar as you posted Trent. I am not too concerned with the philosophy, but if you feel like giving a brief explanation of why one works and the other doesnt.... or why ExecuteScalar should be used over the other I'll take it. If not, I'm just happy to have something that works because I had this issue in quite a few places with after moving this app to ES.

Thanks as always.

Greg, your right it didnt end up being the problem but OUTPUT is propably technically the right return type to use, I knew it was always going to be a single integer return value so I felt ok using a return value. I may indeed refactor, thanks for the input.

Keith Chisarik

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
In short, ExecuteScalar is a direct shot to the data execution of the data layer with no other interpretation.  The SQL command is handed off and handled as is by the data layer whereas there is some interpretted logic in the ExecuteStoredProcedure (which is generally intended for more simple SPROCS). Generally speaking, I always use the ExecuteScalar, ExecuteNonQuery, etc. anytime that I want to execute a SPROC anyway as it is actually slightly better on the performance side of things.  At any rate, I am glad that you got it going.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search