CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2008
    Posts
    3

    Question Working with mssql stored procedures

    I am trying to create a utility to monitor and record database changes. One of the stored procedures that I would like to use is the sp_spaceused.

    Looking at this stored procedure, it returns a value of 1 or 0, but when run in the Query Analyzer, it also returns a recordset detailing the space used details of the database. In C#, how do I review and recordset data? I have tried several iterations of reading this information but it appears as though I can't read it in the application. If the Store Procedure displays a recordset of data in Query analyzer, is it also reasonable to assume that I should be able to read it when called via the application?

    Any help is greatly appreciated.

  2. #2
    Join Date
    Apr 2008
    Location
    United States Of America
    Posts
    21

    Re: Working with mssql stored procedures

    You can use the methods of System.Data.SqlClient library. It has the methods for handling the recordset. In msdn , you can see all the methods detail. Hope that starts up...
    Yes, Possible!!

  3. #3
    Join Date
    Apr 2008
    Posts
    3

    Re: Working with mssql stored procedures

    Thank you for the reply, but I am already using the SQLClient library in an attempt to expose the data elements, but cannot seem to get it to read the data (I am new to C#).

    when I run the sp_spaceused <database> in query analyzer, the return set is like this:

    database_name | database_size | unallocated_space
    ---------------------------------------------------------------------

    and also

    reserved | data | index_size | unused
    ------------------------------------------------

    in essence 2 recordsets of 1 row each. When I execut ethe stored procedure, the only value i seem to get is the return value (0 success, 1 failure). Can someone provide any resource or code sample of how to handle this? I am almost assuradly missing something very simple and basic.

  4. #4
    Join Date
    Jul 2003
    Location
    Bali, Indonesia
    Posts
    103

    Re: Working with mssql stored procedures

    Use the data adapter with store procedure command type...

    MSDN can help
    http://msdn.microsoft.com/en-us/library/59x02y99.aspx

  5. #5
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: Working with mssql stored procedures

    Notification services exist to advise you when data in a database changes, but they are not simple to use.. For an example, this might help: http://www.codeproject.com/KB/database/chatter.aspx
    Last edited by cjard; April 30th, 2008 at 08:36 AM.
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured