Code for soving data to a database