Click here to Skip to main content
15,900,258 members
Home / Discussions / Database
   

Database

 
GeneralRe: Debugging DAO to ADO Conversion Errors Pin
Kyudos14-Apr-15 15:41
Kyudos14-Apr-15 15:41 
AnswerRe: Debugging DAO to ADO Conversion Errors Pin
Kyudos14-Apr-15 16:02
Kyudos14-Apr-15 16:02 
GeneralRe: Debugging DAO to ADO Conversion Errors Pin
Mycroft Holmes14-Apr-15 17:37
professionalMycroft Holmes14-Apr-15 17:37 
QuestionHow to remove a 1000 seperator from a number Pin
Ambertje14-Apr-15 0:35
Ambertje14-Apr-15 0:35 
AnswerRe: How to remove a 1000 seperator from a number Pin
Jörgen Andersson14-Apr-15 1:30
professionalJörgen Andersson14-Apr-15 1:30 
GeneralRe: How to remove a 1000 seperator from a number Pin
Ambertje14-Apr-15 2:04
Ambertje14-Apr-15 2:04 
GeneralRe: How to remove a 1000 seperator from a number Pin
Mycroft Holmes14-Apr-15 14:15
professionalMycroft Holmes14-Apr-15 14:15 
Questionhow to write xml code to manually create pdf without using third party in oracle apex Pin
Member 1159668313-Apr-15 19:28
Member 1159668313-Apr-15 19:28 
QuestionVB.NET MYSQL loop through records while adding Pin
Pauls Pauls13-Apr-15 9:40
Pauls Pauls13-Apr-15 9:40 
QuestionRe: VB.NET MYSQL loop through records while adding Pin
ZurdoDev13-Apr-15 10:09
professionalZurdoDev13-Apr-15 10:09 
AnswerRe: VB.NET MYSQL loop through records while adding Pin
Pauls Pauls13-Apr-15 10:48
Pauls Pauls13-Apr-15 10:48 
AnswerRe: VB.NET MYSQL loop through records while adding Pin
Mycroft Holmes13-Apr-15 14:21
professionalMycroft Holmes13-Apr-15 14:21 
GeneralRe: VB.NET MYSQL loop through records while adding Pin
Pauls Pauls13-Apr-15 20:09
Pauls Pauls13-Apr-15 20:09 
GeneralRe: VB.NET MYSQL loop through records while adding Pin
Mycroft Holmes13-Apr-15 20:39
professionalMycroft Holmes13-Apr-15 20:39 
GeneralRe: VB.NET MYSQL loop through records while adding Pin
Pauls Pauls14-Apr-15 1:47
Pauls Pauls14-Apr-15 1:47 
QuestionPICTUREBOX IMAGE IN VB.NET Pin
Pauls Pauls13-Apr-15 0:18
Pauls Pauls13-Apr-15 0:18 
AnswerRe: PICTUREBOX IMAGE IN VB.NET Pin
Corporal Agarn13-Apr-15 0:35
professionalCorporal Agarn13-Apr-15 0:35 
QuestionSystem.Data.SqlClient.SqlException: Procedure or function 'StaffSearch_sel' expects parameter '@TotalRows', which was not supplied. Pin
indian1437-Apr-15 15:22
indian1437-Apr-15 15:22 
Hi All,

I have a stored procedure as below and I am calling that stored procedure by using ExecuteQuery in asp.net application, I am calling passing the out parameter value but still it is throwing exception. I am not understanding where am I missing, I am debugging and searching too, still can't find any answer.

Can anybody please help me in this any suggestion link or code snippet would be helpful, thanks in advance.

Here is Stored Procedure parameter structure I avoided putting all stored procedure logic here to increase readability, but if you want I can put it here
ALTER PROCEDURE [dbo].[StaffSearch_sel]
    (
    @OverrideSecurity BIT = 0,
    @UserId INT,
    @SchoolYearId INT,
    @Name VARCHAR(500) = NULL,
    @ContractorId INT = NULL,
    @SubcontractorId INT = NULL,
    @SiteId INT = NULL,
    @OrganizationRelationshipIds VARCHAR(500) = NULL,
    @RoleTypeIds VARCHAR(200) = NULL,
    @StaffMemberNeedsAllRoles BIT = 0,  
    @Page INT = 1,
    @RowsPerPage INT = 20,
    @TotalRows INT OUT,
    @SortExpression VARCHAR(50) = 'LastName',
    @SortDirection VARCHAR(15) = 'Ascending'
    )
AS
BEGIN
 ---logic-----
END
And my C# code here
public static List<StaffMemberPOCO> Search(bool staffMemberNeedsAllRoles, bool overrideSecurity, string name, int schoolYearId, int? contractorId, int? subcontractor, int? siteId,
    int[] roleTypeIds, int[] organizationRelationshipIds, int userId, int pageNumber, int rowsPerPage, out int totalRows, string sortExpression, string sortDirection)
{
    using (var context = new ELMSContext())
    {
        var outputParm = new SqlParameter("TotalRows", SqlDbType.Int) { Direction = ParameterDirection.Output };

        List<StaffMemberPOCO> pocos =
            context.ExecuteStoreQuery<StaffMemberPOCO>("exec StaffSearch_sel @OverrideSecurity, @UserId, @SchoolYearId, @Name, @ContractorId, @SubcontractorId, @SiteId, @OrganizationRelationshipIds, @RoleTypeIds, @StaffMemberNeedsAllRoles",
                    new SqlParameter("@OverrideSecurity", overrideSecurity),
                    new SqlParameter("@UserId", userId),
                    new SqlParameter("@SchoolYearId", schoolYearId),
                    new SqlParameter("@Name", name ?? (object)DBNull.Value),
                    new SqlParameter("@ContractorId", contractorId ?? (object)DBNull.Value),
                    new SqlParameter("@SubcontractorId", subcontractor ?? (object)DBNull.Value),
                    new SqlParameter("@SiteId", siteId ?? (object)DBNull.Value),
                    new SqlParameter("@OrganizationRelationshipIds", organizationRelationshipIds == null || organizationRelationshipIds.Count() == 0 ? (object)DBNull.Value : string.Join(",", organizationRelationshipIds)),
                    new SqlParameter("@RoleTypeIds", roleTypeIds == null ? (object)DBNull.Value : string.Join(",", roleTypeIds)),
                    new SqlParameter("@StaffMemberNeedsAllRoles", staffMemberNeedsAllRoles),
                    new SqlParameter("@Page", pageNumber),
                    new SqlParameter("@RowsPerPage", rowsPerPage),
                    outputParm,
                    //new SqlParameter("@TotalRows", SqlDbType.Int) { Direction = ParameterDirection.Output },
                    new SqlParameter("@SortExpression", sortExpression ?? (object)DBNull.Value),
                    new SqlParameter("@SortDirection", sortDirection ?? (object)DBNull.Value)
                    ).ToList();

        totalRows = ((outputParm != null) && !DBNull.Value.Equals(outputParm)) ? int.Parse(outputParm.Value.ToString()) : 0;
        return pocos;
    }
}
And executestorequery is throwing the following exception
System.Data.SqlClient.SqlException: Procedure or function 'StaffSearch_sel' expects parameter '@TotalRows', which was not supplied.
"There is enough hatred in the world, lets spread love compassion and affection."

AnswerRe: System.Data.SqlClient.SqlException: Procedure or function 'StaffSearch_sel' expects parameter '@TotalRows', which was not supplied. Pin
Sascha Lefèvre7-Apr-15 16:42
professionalSascha Lefèvre7-Apr-15 16:42 
GeneralRe: System.Data.SqlClient.SqlException: Procedure or function 'StaffSearch_sel' expects parameter '@TotalRows', which was not supplied. Pin
indian1437-Apr-15 19:59
indian1437-Apr-15 19:59 
GeneralRe: System.Data.SqlClient.SqlException: Procedure or function 'StaffSearch_sel' expects parameter '@TotalRows', which was not supplied. Pin
Sascha Lefèvre7-Apr-15 20:54
professionalSascha Lefèvre7-Apr-15 20:54 
QuestionA data source instance has not been supplied for the data source Pin
indian1436-Apr-15 12:55
indian1436-Apr-15 12:55 
QuestionHow Do I Insert Only Recently Updated Row From Table1 To 2 in MySQL Pin
RevathySanthanam2-Apr-15 4:10
RevathySanthanam2-Apr-15 4:10 
Rant[REPOST] How Do I Insert Only Recently Updated Row From Table1 To 2 in MySQL Pin
Richard Deeming2-Apr-15 4:41
mveRichard Deeming2-Apr-15 4:41 
Questionmultiple joins, works in sql manager but not in asp.net Pin
jkirkerx1-Apr-15 12:47
professionaljkirkerx1-Apr-15 12:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.