I actually changed my code to that after I looked at it more. The way I had it before, I had found as an example in open a sqlConnection.

Thanks firoz.raj