Note that there are some explanatory texts on larger screens.

plurals
  1. PONull object Refrence Error only on web C# asp
    primarykey
    data
    text
    <p>I know this question has been asked but I don't see anything that helps me. What I have is a ticket application that records trouble tickets then sends an email to the right person. When I run this on my machine it works, but on my server I get a <strong>Null object reference</strong> error.</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Collections; using System.Configuration; using System.Data; using System.Web.Security; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using Oracle.DataAccess.Client; using System.Text; using System.Data.OleDb; using System.Windows.Forms; using System.IO; using System.Diagnostics; using System.Net.Mail; namespace Ticketing { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { "201157"; } protected void btn_submit_Click(object sender, EventArgs e) { DateTime dtnow = DateTime.Now; OracleConnection conn = new OracleConnection(Global.oracle); conn.Open(); StringBuilder sqls = new StringBuilder("Insert statment") OracleCommand cmd = new OracleCommand(sqls.ToString(), conn); cmd.CommandType = CommandType.Text; cmd.Parameters.Add(":REASON", txt_reason.Text); cmd.ExecuteNonQuery(); cmd.Dispose(); conn.Close(); // end insert System.Threading.Thread.Sleep(2000); btn_refresh_Click(null, null); btn_email_Click(null, null); //send email MailMessage mail = new MailMessage(); mail.From = new MailAddress("email@email.com"); if (dd_urgency.SelectedValue.ToString() == "Critical") { mail.To.Add("email@email.com"); mail.To.Add("email@email.com"); mail.To.Add("email@email.com"); mail.To.Add(lbl_email.Text); } else if (dd_urgency.SelectedValue.ToString() == "Urgent") { mail.To.Add("email@email.com"); mail.To.Add("email@email.com"); mail.To.Add("email@email.com"); mail.To.Add(lbl_email.Text); } else if (dd_urgency.SelectedValue.ToString() == "Normal") { mail.To.Add("email@email.com"); mail.To.Add(lbl_email.Text); if (dd_location.SelectedValue.ToString() == "XL") { mail.To.Add("email@email.com"); } } else if (dd_urgency.SelectedValue.ToString() == "None") { mail.To.Add("email@email.com"); mail.To.Add(lbl_email.Text); if (dd_location.SelectedValue.ToString() == "XL") { mail.To.Add("email@email.com"); } } mail.IsBodyHtml = true; mail.Subject = ("Ticket Id " + (label_id.Text) +" Urgency: " + dd_urgency.SelectedValue.ToString()) + " At " + (dd_location.SelectedValue.ToString()); mail.Body = txt_reason.Text; SmtpClient smtp = new SmtpClient("basic.smtp.ttu.edu"); try { smtp.Send(mail); } catch (SmtpException ex) { Response.Write("&lt;script&gt;alert('There has been an error please call Travis Jorge at ')&lt;/script&gt;"); } // this.Session.Abandon(); Response.Write("&lt;script&gt;alert('You have submitted your trouble ticket we will be right with you. If you need immediate assistance contact Travis Jorge.')&lt;/script&gt;"); txt_reason.Text = ""; // lbl_email.Text = ""; label_id.Text = ""; dd_location.SelectedIndex = 0; dd_urgency.SelectedIndex = 0; } protected void btn_refresh_Click(object sender, EventArgs e) { OracleConnection conn1 = new OracleConnection(Global.oracle); conn1.Open(); StringBuilder sqls1 = new StringBuilder(Select statement) OracleCommand cmd1 = new OracleCommand(sqls1.ToString(), conn1); cmd1.CommandType = CommandType.Text; OracleDataReader dr = cmd1.ExecuteReader(); dr.Read(); if (dr.HasRows) { if (!dr.IsDBNull(0)) { label_id.Text = dr.GetDecimal(0).ToString(); } } cmd1.Dispose(); conn1.Close(); } protected void btn_email_Click(object sender, EventArgs e) { //Select email for return email OracleConnection conn2 = new OracleConnection(Global.oradb); conn2.Open(); StringBuilder sqls2 = new StringBuilder(select statement) OracleCommand cmd2 = new OracleCommand(sqls2.ToString(), conn2); cmd2.CommandType = CommandType.Text; OracleDataReader dr2 = cmd2.ExecuteReader(); dr2.Read(); if (dr2.HasRows) { if (!dr2.IsDBNull(0)) { lbl_email.Text = dr2.GetString(0).ToString(); } } cmd2.Dispose(); conn2.Close(); } } } </code></pre> <p>I can tell you that all the SQL statements work and this code runs fine on my server without the btn_email function and its associated commands. Any help would be appreciated. Also I know that all the values requested for the objects are available to the page.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload