Finally something a newb like me is starting to understand:
I think Ñuño is correct: if the conn.Open fails and generates an exception, the finally block will execute and try to close the conn object which is not open.
That will in turn generate an error.
Solution: move the conn.open statement out of the try..finally block.
Similar thing for the sql.open statement you've got with the sql.close in the finally block.