Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6069803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:51:43+00:00 2026-05-23T09:51:43+00:00

I can’t make my stored procedure (SQL Server) run with NHibernate. I have following

  • 0

I can’t make my stored procedure (SQL Server) run with NHibernate. I have following mapping:

<sql-query name="udp_MyStoredProc">
    <query-param name="Id" type="Int32" />
    <query-param name="Name" type="String" />
    <return-scalar column="ResId" type="Int32"/>
    EXEC udp_MyStoredProc @Id = :Id, 
        @Name = :Name    
</sql-query>

Within code:

IQuery query = _HibSession.GetNamedQuery("udp_MyStoredProc");
query.SetInt32("Id", id);
query.SetString("Name", name);
var res = query.List();

This results in following exception:

[SQL: EXEC udp_MyStoredProc @Id =
@p0, @Name = @p1] --->
System.Data.SqlClient.SqlException:
Procedure or function udp_MyStoredProc
has too many arguments specified.

I don’t know what’s wrong with the arguments? I also read something about ‘?’ as placeholders for the parameters, but I don’t quite understand it.

Signature of the Stored Procedure:

ALTER PROCEDURE [dbo].[udp_MyStoredProc]
(
    @Id int,
    @Name NVARCHAR(255)
)
AS
BEGIN  ... END

If I do something like this within Server Management Studio, it works:

EXEC udp_MyStoredProc  @Id = 30, @Name = 'test'

thx for any tipps.

sl3dg3

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:51:44+00:00Added an answer on May 23, 2026 at 9:51 am

    I would recommend that you switch on debugging and actually check what the extra argument is. You should be able to see exactly which field is the problem. It may be enough to look at the generated SQL, or you may have to configure a log4net logger (log4net is the debugger that NHibernate uses internally).

    To display the generated SQL in the console, add (or modify) the following property to your NHibernate config file inside the session-factory section:

    <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      ...
      ...
      <property name="show_sql">true</property>
    </session-factory>
    

    EDIT: I can add more details on Log4Net if you need it 🙂

    EDIT 2: Other things to check if you get this error

    1. Your SP should only return a single value
    2. The name of the column returned by your SP should be the same as the name of the column defined in your return-scalar mapping. You can cast the column, eg:

      SELECT field to return AS ResId

    EDIT 3:

    you could try changing your mapping file to:

     <sql-query name="udp_MyStoredProc">
         <return-scalar column="ResId" type="Int32"/>
         EXEC udp_MyStoredProc: ?, ?    
     </sql-query>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can we do following in SQL Server 2005 query with convert function. MaxRegID =
Can the Application Name passed to SQL Server (via the ADO Connection string) be
Can a LINQ enabled app run on a machine that only has the .NET
I have a jquery bug and I've been looking for hours now, I can't
Can anyone give me an example of how to return the following json simply
Can I run this in a Windows command prompt like I can run it
Can anybody tell what is the best(easy) way to sort the following string 'index'
Can't figure out how to do this in a pretty way : I have
Can't work out a way to make an array of buttons in android. This
Can you have submenus with the top level set to checkable in WPF? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.