I am using SMO to create databases and tables on a SQL Server. I want to do so in a transaction. Are both of these methods of doing so valid and equivalent:
First method:
Server server;
//...
server.ConnectionContext.BeginTransaction();
//...
server.ConnectionContext.CommitTransaction();
Second method:
Server server;
// ...
SqlConnection conn = server.ConnectionContext.SqlConnectionObject;
SqlTransaction trans = conn.BeginTransaction();
// ...
trans.Commit();