Hello,
I'm working in c# asp.net and oracle as database. I am binding 10 records in my Dataset ds order by Created_Date desc.
I wanto skip first record to get bind to Dataset ds. How to do it ?
If possible if I can handle it Proc, it is also fine.
My Proc :
Select * from Table T1 where CoverNote = '123456' order by Created_Date desc;
Thank You in advance !

Jignesh KumarRank #91 · 22.9K reputationPosted Mar 3, 2025, 11:23 PM EST
Hello,
You can achieve this in two ways
SELECT * FROM ( SELECT T1.*, ROW_NUMBER() OVER (ORDER BY Created_Date DESC) AS RowNum FROM Table T1 WHERE CoverNote = '123456' ) WHERE RowNum > 1; -- Skips the first rowusing System; using System.Data; using System.Data.OracleClient; public void GetRecords() { string connectionString = "Your Oracle Connection String"; string query = "SELECT * FROM Table T1 WHERE CoverNote = '123456' ORDER BY Created_Date DESC"; using (OracleConnection conn = new OracleConnection(connectionString)) { OracleDataAdapter da = new OracleDataAdapter(query, conn); DataSet ds = new DataSet(); da.Fill(ds); // Skip the first record using condition if (ds.Tables[0].Rows.Count > 1) { // Remove the first row ds.Tables[0].Rows.RemoveAt(0); } // Example: GridView.DataSource = ds; } }Daniel WrightRank #2,947 · 489 reputationPosted Mar 3, 2025, 11:31 AM EST
To skip the first record when binding data to a Dataset in ASP.NET, you can make use of the `Skip` method along with LINQ. Assuming you have already fetched the records from your database and stored them in a DataTable within your Dataset `ds`, here's how you can skip the first record:
// Assuming dt is the DataTable where your records are stored in the Dataset ds DataTable dt = ds.Tables[0]; // Skip the first record var recordsToBind = dt.AsEnumerable().Skip(1).CopyToDataTable(); // Now you can use recordsToBind for further processing or bindingThis code snippet uses LINQ to skip the first record in your DataTable and creates a new DataTable `recordsToBind` that excludes the first row. You can then use this new DataTable for your binding operations.
If you prefer to handle this logic in a stored procedure, you can adjust your SQL query to exclude the first record. One way to achieve this is by using ROW_NUMBER() function in Oracle SQL. Here's an example:
SELECT * FROM ( SELECT t.*, ROW_NUMBER() OVER (ORDER BY Created_Date DESC) AS rn FROM Table T1 WHERE CoverNote = '123456' ) WHERE rn > 1;By adding the ROW_NUMBER() in a subquery and filtering where `rn > 1`, you effectively skip the first record in the result set before returning the data to your ASP.NET application.
I hope this explanation helps you achieve the desired outcome in skipping the first record when binding data to your Dataset in ASP.NET. If you have any further questions or need more clarification, feel free to ask!
Sangeetha SRank #212 · 11.4K reputationPosted Mar 3, 2025, 11:16 PM EST
Instead of binding all 10 records and then skipping the first one, you can adjust your SQL query to fetch records starting from the second one. Here’s an example:
Sushant TorankarRank #3,026 · 476 reputationPosted Mar 4, 2025, 10:21 AM EST
Hello All,
Than you for your wonderful replies, that helped me to fix my issue