Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Object reference not set to an instance of an object.

Object reference not set to an instance of an object.

Scheduled Pinned Locked Moved ASP.NET
helpcsharpdatabasedesign
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Manik Nath
    wrote on last edited by
    #1

    hi friends, i'm using vb.net for devloping a web application. my code shows nothing wrong. but when i click a button to add the entries this error is being shown. my other applications are also developed in the same manner but they do not show error. the only difference in this application is that i'm tring to enter data into database from text property of a label. can this be a cause. i'm unable to figure out please help me. Object reference not set to an instance of an 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.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 198: If DropDownList1.SelectedItem.Text = "Not Available" Then Line 199: insert = "INSERT INTO Transmittal(Project_Name, Username, [Date], [To], Kind_Attn, Title, Drw_Doc_Num, Copies, Rev_Num, Action)" + "VALUES ('" + TextBox7.Text + "', '" + Label10.Text + "', '" + Label17.Text + "', '" + TextBox1.Text + "', '" + TextBox2.Text + "', '" + TextBox10.Text + "', '" + TextBox11.Text + "', '" + TextBox8.Text + "', '" + TextBox5.Text + "', '" + TextBox6.Text + "' )" Line 200: OleDbDataAdapter1.InsertCommand.CommandText = (insert) Line 201: OleDbDataAdapter1.InsertCommand.ExecuteNonQuery() Line 202: OleDbConnection1.Close() Source File: C:\Inetpub\wwwroot\OM\trans.aspx.vb Line: 200 Stack Trace: [NullReferenceException: Object reference not set to an instance of an object.] OM.trans.Button4_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\OM\trans.aspx.vb:200 System.Web.UI.WebControls.Button.onclick(EventArgs e) +108 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1263

    C 1 Reply Last reply
    0
    • M Manik Nath

      hi friends, i'm using vb.net for devloping a web application. my code shows nothing wrong. but when i click a button to add the entries this error is being shown. my other applications are also developed in the same manner but they do not show error. the only difference in this application is that i'm tring to enter data into database from text property of a label. can this be a cause. i'm unable to figure out please help me. Object reference not set to an instance of an 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.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 198: If DropDownList1.SelectedItem.Text = "Not Available" Then Line 199: insert = "INSERT INTO Transmittal(Project_Name, Username, [Date], [To], Kind_Attn, Title, Drw_Doc_Num, Copies, Rev_Num, Action)" + "VALUES ('" + TextBox7.Text + "', '" + Label10.Text + "', '" + Label17.Text + "', '" + TextBox1.Text + "', '" + TextBox2.Text + "', '" + TextBox10.Text + "', '" + TextBox11.Text + "', '" + TextBox8.Text + "', '" + TextBox5.Text + "', '" + TextBox6.Text + "' )" Line 200: OleDbDataAdapter1.InsertCommand.CommandText = (insert) Line 201: OleDbDataAdapter1.InsertCommand.ExecuteNonQuery() Line 202: OleDbConnection1.Close() Source File: C:\Inetpub\wwwroot\OM\trans.aspx.vb Line: 200 Stack Trace: [NullReferenceException: Object reference not set to an instance of an object.] OM.trans.Button4_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\OM\trans.aspx.vb:200 System.Web.UI.WebControls.Button.onclick(EventArgs e) +108 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1263

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      First, before I answer your question I am going to send you off to read an article about writing secure SQL Code. The reason for this is that your code is very heavily susceptable to a SQL Injection Attack. SQL Injection Attacks and Some Tips on How to Prevent Them[^] manik nath wrote: OleDbDataAdapter1.InsertCommand.CommandText = (insert) There are three possibilities here, one of which I'm discounting because the previous line creates the value. Possibility 1: OleDbDataAdapter1 is null Possibility 2: The InsertCommand property on OleDbDataAdapter1 is null. Does this help?


      My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

      M 1 Reply Last reply
      0
      • C Colin Angus Mackay

        First, before I answer your question I am going to send you off to read an article about writing secure SQL Code. The reason for this is that your code is very heavily susceptable to a SQL Injection Attack. SQL Injection Attacks and Some Tips on How to Prevent Them[^] manik nath wrote: OleDbDataAdapter1.InsertCommand.CommandText = (insert) There are three possibilities here, one of which I'm discounting because the previous line creates the value. Possibility 1: OleDbDataAdapter1 is null Possibility 2: The InsertCommand property on OleDbDataAdapter1 is null. Does this help?


        My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

        M Offline
        M Offline
        Manik Nath
        wrote on last edited by
        #3

        hi colin, i did not get you exactly, what did you want to say. please could you elaborate both the posiibilities a little more.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups