Absolutely - you'd want to abstract that out into a data access class.
If I recall, you and Bonnie and I (and maybe some others) had a lengthy exchange back around 1/21 or 1/22 of this past January on this subject. (Only reason I remember the specific date is because we were getting pounded with two feet of snow that day!)
Kevin