Webmatrix, Access Database and SQL syntaxhttp://forums.asp.net/t/1768953.aspx/1?Webmatrix+Access+Database+and+SQL+syntaxTue, 14 Feb 2012 11:23:16 -050017689534829733http://forums.asp.net/p/1768953/4829733.aspx/1?Webmatrix+Access+Database+and+SQL+syntaxWebmatrix, Access Database and SQL syntax <p>Hi,</p> <p>I've a classic asp site with an Access Database and i migrate this to cs webmatrix.</p> <p>Actually, it's impossible to change my access database to mySQL or other SQL server for a lot of reasons.</p> <p>i want make a pagination without webgrid helper like <a href="http://www.mikesdotnetting.com/Article/150/Web-Pages-Efficient-Paging-Without-The-WebGrid" target="_blank"> http://www.mikesdotnetting.com/Article/150/Web-Pages-Efficient-Paging-Without-The-WebGrid</a> but FETCH function doesn't work with Access like LIMIT.</p> <p>Anyone have solution ?</p> <p>Thanks.</p> 2012-02-13T12:09:12-05:004829830http://forums.asp.net/p/1768953/4829830.aspx/1?Re+Webmatrix+Access+Database+and+SQL+syntaxRe: Webmatrix, Access Database and SQL syntax <p>Access doesn't support any kind of record paging internally. </p> <p></p> 2012-02-13T13:01:21-05:004831047http://forums.asp.net/p/1768953/4831047.aspx/1?Re+Webmatrix+Access+Database+and+SQL+syntaxRe: Webmatrix, Access Database and SQL syntax <p>If you love 'acrobatic' SQL this is a simulation of paging with an Access&nbsp;<em>MyTable</em> table with an <em>Id</em> field as primary key:</p> <pre class="prettyprint">SELECT MyTable.* FROM MyTable WHERE MyTable.Id In ( SELECT TOP 10 A.Id FROM [ SELECT TOP 30 MyTable.Id FROM MyTable ORDER BY MyTable.Id ]. AS A ORDER BY A.Id DESC ) ORDER BY MyTable.Id</pre> <p>The SQL statement queries the top 30 records, reverses the order, queries the top 10, and then selects the rows from the table that match, sorting in forward order again.</p> <p>So&nbsp;it extracts the records from 21 to 30 from the table.</p> <p>It's not mine, and you can see more details at <a href="http://stackoverflow.com/questions/8627032/ms-access-limit-x-y"> http://stackoverflow.com/questions/8627032/ms-access-limit-x-y</a>.</p> <p>A problem is that the TOP clause doesn't accept parameters, so you must build the statement inserting the offset value (replacing '30') concatenating strings (pay attention to SQL Injection).</p> 2012-02-14T07:32:32-05:004831480http://forums.asp.net/p/1768953/4831480.aspx/1?Re+Webmatrix+Access+Database+and+SQL+syntaxRe: Webmatrix, Access Database and SQL syntax <p>i found this code and i try it.</p> <p>it works great but the performances are bad.</p> <p>Thanks for your help, i keep my old code for the moment.</p> 2012-02-14T11:23:16-05:00