object reference not set to an instance of object

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • varunapj
    New Member
    • Feb 2008
    • 5

    object reference not set to an instance of object

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullRefe renceException: Object reference not set to an instance of an object.

    Source Error:


    Line 25: Protected Sub Button1_Click(B yVal sender As Object, ByVal e As System.EventArg s) Handles Button1.Click
    Line 26:
    Line 27: con.ConnectionS tring = "Data Source=varun-150d9d396\sqlex press;Initial Catalog=user;In tegrated Security=True;P ooling=False"
    Line 28: con.Open()
    Line 29: pr = DropDownList1.S electedValue


    Source File: C:\Documents and Settings\V A R U N S\My Documents\Visua l Studio 2005\WebSites\h ome\newb.aspx.v b Line: 27

    Stack Trace:


    [NullReferenceEx ception: Object reference not set to an instance of an object.]
    newb.Button1_Cl ick(Object sender, EventArgs e) in C:\Documents and Settings\V A R U N S\My Documents\Visua l Studio 2005\WebSites\h ome\newb.aspx.v b:27
    System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +96
    System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String eventArgument) +116
    System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring eventArgument) +31
    System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler sourceControl, String eventArgument) +32
    System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +72
    System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +3838


    Can any one help me i can proceed becoz of this error
    Last edited by jhardman; Feb 23 '08, 04:30 AM. Reason: moved to .Net forum. ASP forum is for "classic" ASP
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    This is a compilation error for ASP.NET

    Post in the .NET forum for better answers. Off the top of my head though it seems like you connection string is probably wrong. It might also depend if your server is running ASP.NET 1.0 or 2.0 for what kind of connection string you will need. I think I had problems until I realized this too.

    Comment

    Working...