-
ASP.NET 2.0 -- Code not executing
I have an ASP.NET 2.0 web application. This application has a command button that triggers some code to happen. It works on my development box; but, when I deploy to my test server, it does not appear to execute. The page appears to just repost. I included some Response.Write statements to use for debugging and none of them are displaying on the reposted page. The code is posted below:
protected void btnExecute_Click(object sender, EventArgs e)
{
String strPath;
Microsoft.Office.Interop.Excel.Application objExcel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook objWorkbook = null;
Object missing = Type.Missing;
if (Page.IsPostBack)
{
Response.Write("Button clicked");
try
{
connProviders.ConnectionString = SqlDataSource1.ConnectionString;
SqlCommand cmdReports = new SqlCommand();
cmdReports.Connection = connProviders;
cmdReports.CommandType = CommandType.StoredProcedure;
cmdReports.CommandText = "GetReports";
SqlDataAdapter daReports = new SqlDataAdapter(cmdReports);
DataSet dsReports = new DataSet("Reports");
Response.Write("Fill dsReports");
daReports.Fill(dsReports);
Response.Write("dsReports filled");
foreach (ListItem l in lstProviders.Items)
{
if (l.Selected == true)
{
foreach (TreeNode pn in trvReports.Nodes)
{
foreach (TreeNode cn in pn.ChildNodes)
{
if (cn.Checked == true)
{
foreach (DataRow d in dsReports.Tables[0].Rows)
{
if (cn.Text == d["NodeName"].ToString())
{
strPath = d["FileLocation"].ToString() + l.Text + @"\" + d["NodeName"].ToString() + @"\" + l.Text + " - " + d["ReportName"].ToString() + "." + d["ReportType"].ToString();
if (File.Exists(strPath))
{
try
{
switch (d["ReportType"].ToString())
{
case "xls":
Response.Write("Made it to Excel Activation");
objWorkbook = objExcel.Workbooks.Open(strPath, 1, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
Response.Write("Opened Excel object");
objWorkbook.PrintOut(missing, missing, missing, missing, missing, missing, missing, missing);
Response.Write("Printed Excel object");
break;
}
}
catch (Exception DocEx)
{
MessageBox.Show("Problem with file " + strPath);
}
finally
{
if (objWorkbook != null)
{
objWorkbook.Close(0, missing, missing);
}
}
}
}
}
}
}
}
}
}
objExcel.Quit();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
I'm fairly new to ASP.NET and am stuck. Any help/guidance is much appreciated. Thanks in advance.
Similar Threads
-
By clean in forum ASP.NET
Replies: 0
Last Post: 02-14-2006, 02:05 PM
-
By kil4h in forum ASP.NET
Replies: 3
Last Post: 11-08-2005, 05:52 AM
-
By Phil Weber in forum .NET
Replies: 632
Last Post: 10-01-2003, 12:00 AM
-
By Glen Kunene in forum Java
Replies: 25
Last Post: 04-22-2002, 05:45 PM
-
Replies: 150
Last Post: 03-04-2002, 06:40 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|