Manj N

Manj N

  • NA
  • 148
  • 90.5k

i am getting error as nullReferenceException

Jul 31 2013 4:58 AM
i am getting error as Object reference not set to an instance of an object.
NullReferenceException was unhandled by user..


public partial class _Default : System.Web.UI.Page
{
    SqlConnection MyConnection = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"].ToString());
    SqlCommand MyCommand= new SqlCommand();
    string query;
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void submit_Click(object sender, EventArgs e)
    {
        query="INSERT INTO tablem (name,password) VALUES (" + name +"," + password +")";
        try
        {
        }
        catch (NullReferenceException)
        {
            Console.WriteLine("error ");
        }
    }  
}

Answers (19)