Dong Lam Trien

Dong Lam Trien

  • 830
  • 986
  • 147.3k

when using Stored Procedure called from C# ?

Jun 20 2014 3:53 AM
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 ?

Answers (17)