1
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 row
using 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;
}
}
0
Hello All,
Than you for your wonderful replies, that helped me to fix my issue
0
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:
string query = "SELECT * FROM (SELECT * FROM your_table ORDER BY Created_Date DESC)
WHERE ROWNUM <= 10 AND ROWNUM > 1";
0
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 binding
This 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!
