Monday, August 16, 2010

How can we select data from SQL Server to GridView fastly.?

How can we select data from SQL Server to GridView fastly. I have to show 2000 records at a time. I am using a procedure which has cursors and is quite slow on hostingHow can we select data from SQL Server to GridView fastly.?
Use Stored Procedure and for getting data use indexes clustered and also non clustrere.


As per paging issue gridview show only 1000 records per pageHow can we select data from SQL Server to GridView fastly.?
I'd advise to change your code. Cursors aren't usually the only way of performing a task and they have massive overheads.





Can you post your code or what you're wanting to do so we can see if it can be done another way?





*EDIT*





Hi again Sam, looks like you've run out of space on the additional info. If you want to email me the cursor I'll try and have a look at it over christmas.





My emails filetransferboy @ yahoo.co.uk
hello frnd simple use store procedure for this





-- ========================================鈥?br>

-- Template generated from Template Explorer using:


-- Create Procedure (New Menu).SQL


--


-- Use the Specify Values for Template Parameters


-- command (Ctrl-Shift-M) to fill in the parameter


-- values below.


--


-- This block of comments will not be included in


-- the definition of the procedure.


-- ========================================鈥?br>

SET ANSI_NULLS ON


GO


SET QUOTED_IDENTIFIER ON


GO


-- ========================================鈥?br>

-- Author: %26lt;Author,,Name%26gt;


-- Create date: %26lt;Create Date,,%26gt;


-- Description: %26lt;Description,,%26gt;


-- ========================================鈥?br>

CREATE PROCEDURE SP_SelectData


as





select * from tbl_name





---------------------------








and call with code and use datatable object for this and bind it .


more help mail me madangdhiman@yahoo.co.in
The use of a cursor is absolutely no needed. Cursors will slow down your code.





Write the Procedure as such


CREATE PROC GetEmployee


( @prmEmpId int )


AS


SELECT * FROM Employee WHERE ID = ISNULL(@prmEmpId, ID)





The complete guide that teaches you to display the record set in a gridvew is here:





http://msdn.microsoft.com/en-us/library/鈥?/a>





Hope this helps.

No comments:

Post a Comment