Hi, One way of doing this could be:
select *
from orders a
where a.customer = 'A'
and ( a.id in (select top(2) id
from orders b
where b.customer = a.customer
and b.id < 26
order by b.id desc)
or
a.id in (select top(3) id
from orders b
where b.customer = a.customer
and b.id >= 26
order by b.id asc))
The above (not tested) should fetch 5 rows. ID 26 and 2 rows from both sides
The need to optimize rises from a bad design.My articles[^]
Try this:
ToolStripMenuItem itm = sender as ToolStripMenuItem;
if (itm != null)
{
ContextMenuStrip cm = (ContextMenuStrip)itm.Owner;
MessageBox.Show(cm.SourceControl.ToString());
}
Obviously I'm only showing the control in a MessageBox. You can do whatever you need to with it.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” I wouldn't let CG touch my Abacus! When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
It's the grids doing it, not the database access as such. If you can "page" the results for the grids, only loading as many rows as will be displayed, it should speed up a bit.
..and water fell from the sky like rain.