using System.Data;
using System.Data.SqlClient;
namespace ExportaExcel
{
public class ObterDados
{
#region Métodos
public DataTable Obter()
{
string ConnectionString = @"Data Source=NTAPELUSO\SQLEXPRESS;User Id=usuario;Password=and@123;Initial Catalog=CODIGOFONTE;";
DataTable lObjDataTable = new DataTable();
using (SqlConnection connection = new SqlConnection(ConnectionString))
{
using (SqlCommand lObjSqlCommand = new SqlCommand())
{
lObjSqlCommand.Connection = connection;
lObjSqlCommand.CommandText = "SELECT * FROM COLABORADOR";
using (SqlDataAdapter lObjDataAdpter = new SqlDataAdapter())
{
lObjDataAdpter.SelectCommand = lObjSqlCommand;
lObjDataAdpter.Fill(lObjDataTable);
}
}
}
return lObjDataTable;
}
#endregion
}
}