Hi Anne,
I can help out a little here.
David Lammie and Isobel McMichael had at least 3 sons - Robert (5 March 1844), William (22 April 1846), and George (5 September 1848), all born in Kirkconnel. As these are OPR records you should assume that these are christening dates.
David then married Jane Gall 17 November 1853 in Kirkconnel.
Robert married Jeanie McGavin in Riccarton in 1871. This is the grave highlighted by Alex in an earlier posting.
A David Lammie died in Kirkconnel in 1898 aged 84. This would be consistent with your census record giving a birth c1814. The reference on Scotlands People is 834/00 0006. This should give you his parents.
My money would be on John Lambie and Margaret Lambie who had a William 'Lambie' christened in Kirkconnel 12 December 1802.
Again, all this would be consistent with the information posted by Alex.
If you are interested, I host the Lambie mailing list on Rootsweb to further research of all Lambie, Lammie, and Lamie variants.
Hope this helps,
Paul