GSquared (2/18/2011)
David Burrows (2/18/2011)
string strsql = "";
strsql += " Select '' AS [CustomerId],' ---Select Customer --- ' AS [CompanyName] ";
strsql += " Union Select CustomerId, CompanyName ";
strsql += " From testCustomers ";
strsql += " Order by CompanyName ";
You can run into a problem with that, if there's a company name that comes earlier in the sort sequence than the "column header". I usually add a "Sequence" column, hard-coded to 0 for the header, and 1 for the query under the union, and then order by that first, to force the header to stay on top. (Had to do that in a few places in an Access front-end application.)
Just something to think about on it.
Yep knew that, I've had to do the same as you several times 🙂
But took it that the select text has a leading space would overcome that (unless there is a CompanyName with a leading space)
Far away is close at hand in the images of elsewhere.
Anon.