fix connection string generation and basic error handling