I am getting an "Connection must be valid and open" error. After some research I have found two possible reasons for this: malformed sql or bad connection string. Since the error is being thrown on a second .executescalar statement I will assume the connection string is working. I have two questions. First - if I can cut and paste the sql statement into mySql's query browser and it returns the information, is the sql malformed? (e.g. select user_id from cms.accounts where [EMAIL="firstname.lastname@example.org'"]email@example.com'[/EMAIL]) Next - are there other reasons for the error message.