I was wondering if the below way of handling multiple sql's within the same using
statement is correct, I have tested this in a project and it works but would it not be better to wrap each sql in it's own using statement? Which option is a better coding practice?
Using cmd As New SqlCommand()
cmd.Connection = conn
cmd.CommandType = CommandType.Text
sql = "Select * From blah"
cmd.CommandText = sql
theValue = cmd.ExecuteScalar()
sql = "Update tbl1 Set a = b"
cmd.CommandText = sql
cmd.ExecuteScalar()
sql = "Update tbl2 Set x = y"
cmd.CommandText = sql
cmd.ExecuteNonQuery()
End Using
Thanks