using System; using System.Data; using System.Data.Common; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class ViewCOE : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("~/App_Data/2007COERaw.xls") + ";" + "Extended Properties=\"Excel 8.0;HDR=YES;\""; DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb"); DbDataAdapter adapter = factory.CreateDataAdapter(); DbCommand selectCommand = factory.CreateCommand(); selectCommand.CommandText = "SELECT [Type of Event], ID as [COE ID], [Primary Lead Portfolio], [Event Title], [Key Partners], " + "[Event Description], [Primary Target Segment], [Secondary Target Segment(s)], " + "[Proposed Date/Time], [End Date/Time], Location " + "FROM [COE2007$] " + "WHERE [Type of Event] IN ('Event', 'Other') " + //"AND [Primary Lead Portfolio] = 'Youth & Sports Board' " + "ORDER BY [Type of Event], [Proposed Date/Time], ID"; DbConnection connection = factory.CreateConnection(); connection.ConnectionString = connectionString; selectCommand.Connection = connection; adapter.SelectCommand = selectCommand; DataSet events = new DataSet(); adapter.Fill(events); coeGridView.DataSource = events.Tables[0].DefaultView; coeGridView.DataBind(); } }