19
Answers

i am getting error as nullReferenceException

Manj N

Manj N

11y
2.6k
1
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)