edited handling errors in Select Method, fixed spaces in sql line