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

    when using Stored Procedure called from C# ?

    In SQL Server 2005 Stored Procedure I have the following:

    Code:
    CREATE FUNCTION [dbo].[LISTSTAFF]()
    RETURNS TABLE
    AS    
    RETURN(select * from tblStaff);
    In C#2005 I assign staff style table for gridview an error, can you help me fix this ?


    Code:
    ...
    SqlCommand cmd = new SqlCommand("LISTSTAFF", cnn);
    cmd.CommandType = CommandType.StoredProcedure;
    gridview.DataSource = cmd.ExecuteReader();// waring error in here
    ...
    I want assign list database style table for gridview.DataSource =... how assign ?

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: when using Stored Procedure called from C# ?

    Try to EXECUTE the query, and THEN assign it.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Sep 2007
    Posts
    405

    Re: when using Stored Procedure called from C# ?

    I try to run the EXEC good as when brought into the program will not run

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: when using Stored Procedure called from C# ?

    The QUERY doesn't run? That means it's wrong
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Sep 2007
    Posts
    405

    Re: when using Stored Procedure called from C# ?

    it don't run in program C# but I did it.

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