ExcelTemplate xlt = new ExcelTemplate();
OleDbConnection Conn = new OleDbConnection();
DataTable EmployeeDt = null;
try
{
//Load data from database
Conn.ConnectionString = Application["connstring"].ToString();
//--- SQL Query for employee information
string EmployeeSQL = "SELECT FirstName + ' ' +
LastName As Name, Title " +
"FROM Employees WHERE EmployeeID=?";
OleDbCommand CmdEmployee = new OleDbCommand(EmployeeSQL, Conn);
CmdEmployee.Parameters.Add("@EmployeeID", EmployeeId);
OleDbDataAdapter AdptEmployee = new OleDbDataAdapter(CmdEmployee);
EmployeeDt = new DataTable();
AdptEmployee.Fill(EmployeeDt);
//Sort DataView
DataView dv = EmployeeDt.DefaultView;
dv.Sort = "Employee DESC";
//Bind DataView
xlt.BindData(dv, "Employee",xlt.CreateDataBindingProperties());
}
|