Changed SQL code

Changed the SQL connection code to work with the changes in the
database.