Unfortunatly InfoPath does not have the functionality to convert the main datasource from XML to a database.
Reference:
http://msdn.microsoft.com/en-us/library/bb250994.aspx
(Look for the note in the middle of the page)
In my opinion InfoPath support for databases is not very robust anyway. I don't use databases as a main datasource very often anymore. I usually handle database interactions in secondary datasources and use C# managed code for any insert/update actions I need.
If I really needed to do this conversion here is how I would do it:
At the end of the day you template is simply a collection of XML documents. Create two new templates. In one, create an identical main datasource as you already have. In the other, create the datasource you want attached to your database. Do a Save As Source Files... and use Beyond Compare or such to compare the two templates. Learn what is different between a database connection and a XML connection and make those changes by hand in your target template (make a backup first).