SQL
asp:ObjectDataSource ID="ObjectDataSource2"
runat="server"
onselecting="ObjectDataSource2_Selecting"
EnablePaging="true"
SelectCountMethod="GetItemsCount"
SelectMethod="BindItems"
StartRowIndexParameterName="startRowIndex"
MaximumRowsParameterName="maximumRows"
TypeName="eSova.Utilities.RecordUtilities" >And method which calling:
SQL
public static DataTable BindItems(int category,int search,int startRowIndex,int maximumRows)
{
DataTable table = new DataTable();
using (SqlConnection connection = new SqlConnection())
{
ConnectionUtilities.OpenConnection(connection);
SqlTransaction transaction = connection.BeginTransaction();
try
{
SqlCommand command = new SqlCommand("GetItems",connection,transaction);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@RowIndex", SqlDbType.Int, 4).Value = startRowIndex;
command.Parameters.Add("@MaxRows", SqlDbType.Int, 4).Value = maximumRows;
SqlDataAdapter adapter = new SqlDataAdapter(command);
adapter.Fill(table);
transaction.Commit();
}
catch
{
transaction.Rollback();
}
}
return table;
}SQL
create proc [dbo].[GetItems](@RowIndex int,@MaxRows int)SQL
as
declare @StartRows int
declare @EndRow int
set @StartRows=(@RowIndex+1)
set @EndRow=(@StartRows+@MaxRows)
select *
from ( select id, name, filepath, descript, itemlanguage,
filetypeid, ROW_NUMBER() over (ORDER by id)as row FROM Items)as NumberesItems
where row between @StartRows and @EndRowAnd finally StoredProcedure
SQL
create proc [dbo].[GetItems](@RowIndex int,@MaxRows int)
as
declare @StartRows int
declare @EndRow int
set @StartRows=(@RowIndex+1)
set @EndRow=(@StartRows+@MaxRows)
select *
from ( select id, name, filepath, descript, itemlanguage,
filetypeid, ROW_NUMBER() over (ORDER by id)as row FROM Items)as NumberesItems
where row between @StartRows and @EndRowMy storedProcedure work just fine and return in all items from table. But when i analyze code i got breakpoint on return and table variable is without records. Also i cant debugg stored procedure cause i dont have permission on server sysadmin but just I got dbowner.
I use .Net 4, MS SQL Server 2012 and version of Management studio is 11.0.

Iftikar HussainRank #423 · 5.9K reputationPosted Aug 7, 2013, 8:25 AM EDT
Try like this, don't use ADO.NET transaction
Regards,
Iftikar
Alexander Dracka16 reputationPosted Aug 7, 2013, 9:20 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 7, 2013, 9:35 AM EDT
Regards,
Iftikar
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 7, 2013, 9:38 AM EDT
SqlCommand command = new SqlCommand("GetItems",connection,transaction);
Regards,
Iftikar
Alexander Dracka16 reputationPosted Aug 7, 2013, 10:27 AM EDT