Opening and closing connections is cheap. ADO pools connections. It keeps them open for the next statement that comes along. So when you call open()
, you get exclusive use of the connection, but close()
just returns it to the pool.
If you're running multiple statements, concentrate more on things like error handling. You can run multiple statements in one block of SQL, and multiple blocks of SQL one after the other on an open connection. But if one statement fails, do you go on to the next one, or roll back the previous ones, and do you want to manage this in C# or in the SQL. And which statements, if any, return results? These are the factors that should determine where you split your SQL.
It's pretty unusual to create tables in your application code. Have you looked at DB projects ?