public static DataTable ExecutaSelect(string sql, SqlParameter[] parametros) { using (SqlConnection cx = ConexaoBD.GetConexao()) { using (SqlDataAdapter adapter = new SqlDataAdapter(sql, cx)) { DataTable tabela = new DataTable(); adapter.Fill(tabela); return(tabela); } } }
public static void ExecutaSQL(string sql, SqlParameter[] parametros) { using (SqlConnection conexao = ConexaoBD.GetConexao()) { using (SqlCommand comando = new SqlCommand(sql, conexao)) { if (parametros != null) { comando.Parameters.AddRange(parametros); } comando.ExecuteNonQuery(); } conexao.Close(); } }