Escolar Documentos
Profissional Documentos
Cultura Documentos
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Data.SqlClient;
System.Data;
namespace Graficos
{
class ConnectionFactory
{
public string Msgerro = "";
public SqlConnection conectar()
{
SqlConnection con = new
SqlConnection(Graficos.Properties.Settings.Default.conexao);
return con;
}
public DataTable listar(string Consulta, Boolean StoredProc)
{
DataTable lista = new DataTable();
SqlConnection con = this.conectar();
try
{
SqlCommand cmd = new SqlCommand(Consulta, con);
if (StoredProc)
cmd.CommandType = CommandType.StoredProcedure;
else
cmd.CommandType = CommandType.Text;
con.Open();
SqlDataReader tabela = cmd.ExecuteReader();
lista = new DataTable();
lista.Load(tabela);
}
catch (Exception err)
{
Msgerro = "Erro na consulta " + err.Message;
}
return lista;