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 725679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:21:51+00:00 2026-05-14T06:21:51+00:00

I am making a windows service to be able to run operations on a

  • 0

I am making a windows service to be able to run operations on a sql server database (insert, edit, etc) and invoke Stored Procs.

However, is there a way for me to know the type of the SP? When invoking from C#, I need to knof if it is returning 1 value, or more, or none (so I can use executereader, scalar, etc)?

Thanks

  • 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-14T06:21:51+00:00Added an answer on May 14, 2026 at 6:21 am
    1. A non-query is usually called with SqlCommand.ExecuteNonQuery(). But it’s valid to run it as SqlCommand.ExecuteReader(). The only difference is that the first call to DataReader.Read() returns false for a stored procedure that does not return a resultset.
    2. A rowset is run as SqlCommand.ExecuteReader(). The first call to DataReader.Read() will return true.
    3. A scalar is just a shortcut for a rowset with one column and one row.

    So you can use ExecuteReader in all three scenarios.

    Though it seems unnecessary for your question, you can retrieve meta-data for the resultset using the fmtonly option. The setting causes the statement to return the column information only; no rows of data are returned. So you could run:

    SET FMTONLY ON;
    EXEC dbo.YourProc @par1 = 1;
    SET FMTONLY OFF;
    

    Executing this as a CommandText from C#, you can examine the column names the stored procedure would return.

    To verify that a stored procedure run in this way does not produce any side effects, I ran the following test case:

    create table table1 (id int)
    go
    create procedure YourProc(@par1 int)
    as
    insert into table1 (id) values (@par1)
    go
    SET FMTONLY ON;
    EXEC dbo.YourProc @par1 = 1;
    SET FMTONLY OFF;
    go
    select * from table1
    

    This did not return any rows. So the format-only option makes sure no actual updates or inserts occur.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a Windows service which needs to continuously check for database entries
I'm making a program which the user build directories (not in windows, in my
I am hosting a WCF service in a Windows Service on one of our
We have a windows service running under a network account that calls and runs
I am making a c# windows app that has one MainForm and many User
I am making a game for windows, mac and GNU, I can built it
I'm making a little app for calculating tips for Windows Phone 7 and I
I'm making a small tip calculator for the Windows Phone 7 and I'm almost
I am making a desktop application in C#, Visual Studio 2010 on Windows XP
I have created one windows service which send an email notifications to users (list

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.