protected DataTable ListarTabela() { using (SqlConnection cx = ConexaoBD.GetConexao()) { string sql = "sp_Listar" + ProcedureName(); return(Metodos.ExecutaSelect(sql, null)); } }
/// <summary> /// Método para consultar 1 registro /// </summary> /// <param name="id"></param> /// <returns></returns> public PadraoVO Consulta(int id) { using (SqlConnection cx = ConexaoBD.GetConexao()) { string sql = "sp_Consulta" + ProcedureName(); SqlParameter[] parametros = { new SqlParameter("id", id) }; return(ExecutaSqlLocal(sql, parametros)); } }
public static void ExecutaSQL(string sql, SqlParameter[] parametros) { using (SqlConnection conn = ConexaoBD.GetConexao()) { SqlCommand comando = new SqlCommand(sql, conn); comando.Parameters.AddRange(parametros); comando.CommandType = CommandType.StoredProcedure; comando.ExecuteNonQuery(); } }
public static DataTable ExecutaFunction(string sql, SqlParameter[] parametros) { using (SqlConnection conn = ConexaoBD.GetConexao()) { using (SqlDataAdapter adapter = new SqlDataAdapter(sql, conn)) { if (parametros != null) { adapter.SelectCommand.Parameters.AddRange(parametros); } adapter.SelectCommand.CommandType = CommandType.StoredProcedure; DataTable tabela = new DataTable(); adapter.Fill(tabela); return(tabela); } } }