Last post Aug 05, 2011 09:53 AM by limno
Aug 02, 2011 10:28 AM|jitendra2cool|LINK
The below stored procedure is running perfectly in SQL server manager...
But when I try to run my aspx file > gridview > sqldatasource > Stored Procedure ... Then Gridview is not displaying any record.
Although I can see records by SQL Query.
CREATE PROCEDURE [dbo].[StoredProcedure2] (@Doc_ty Varchar(2))ASBEGIN Declare @Query Varchar(MAX)Set @Query = 'Select * from qtdocdet'Exec (@Query)END
Kindly Suggest me the solution.
Aug 02, 2011 10:33 AM|bhavik.y.shah|LINK
You are binding grod directly from SQLDataSource or creating template fields in Gridview and then assigning SP as a DataSource.
Aug 03, 2011 10:55 PM|Decker Dong - MSFT|LINK
Set @Query = 'Select * from qtdocdet'
Since you've got only a very simple sql statement. You don't need to use Exec, but just write directly to make a stored proc, and then import it into your GridView with the help of the Wizard of SqlDataSource.
SqlDataSource's Wizard with sp, see at：http://msdn.microsoft.com/en-us/library/k10148y1.aspx
Aug 05, 2011 09:53 AM|limno|LINK
You need to supply the parameter in your datasource for your stored procedure to make it work. Or you make the parameter optional in your stored procedure:
By the way, you are not using the parameter, you can remove it for now. When you learn how to code T-SQL, please don't start with dynamic query first. You can code many of your queries without using dynamic query. There is a serious security issue and performance
issue too if you don't understand your dynamic query fully.