Hi,
http://aspsnippets.com/Articles/Custom-Paging-in-ASP.Net-GridView-using-SQL-Server-Stored-Procedure.aspx
I want to do custom paging descibed in above link, but using Microsoft Access not sql server.
so I wrote this:
private void GetProductsPageWise(int pageIndex)
{
string constring = Connection.ConnectionString();
using (OleDbConnection con = new OleDbConnection(constring))
{
using (OleDbCommand cmd = new OleDbCommand("SELECT ROW_NUMBER() OVER (ORDER BY [ID] ASC) AS RowNumber ,* INTO #Results FROM [tbl_news] SELECT @RecordCount = COUNT(*) FROM #Results SELECT * FROM #Results WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1 DROP TABLE #Results", con))
{
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@PageIndex", pageIndex);
cmd.Parameters.AddWithValue("@PageSize", 3);
cmd.Parameters.Add("@RecordCount", OleDbType.Integer, 4);
//cmd.Parameters["@RecordCount"].Direction = ParameterDirection.Output;
con.Open();
OleDbDataReader idr = cmd.ExecuteReader();
rpt.DataSource = idr;
rpt.DataBind();
idr.Close();
con.Close();
int recordCount = Convert.ToInt32(cmd.Parameters["@RecordCount"].Value);
this.PopulatePager(recordCount, pageIndex);
}
}
}
but it throws this error:
Syntax error (missing operator) in query expression 'ROW_NUMBER() OVER (ORDER BY [ID] ASC)'.
so is there any solution?
thanks