نمایش نتایج 1 تا 1 از 1

نام تاپیک: خطای System.NullReferenceException: Object reference not set to an instance of an object.

  1. #1
    منتظر تایید آدرس ایمیل
    تاریخ عضویت
    شهریور 1387
    سن
    35
    پست
    14

    خطای System.NullReferenceException: Object reference not set to an instance of an object.

    سلام. من یه برنامه نوشتم. موقع دیباگ کردن با خود ویژوال استودیو خطایی نمی ده. بعد setup ش رو ساختم. موقعی که نصب می کنم و اجرا می کنم و روی دکمه ای که به دیتابیس وصل می شه کلیک می کنم خطا می ده. بقیه ی جاها خطا نمی ده. خطاش هم اینه.

    Error.jpg

    این هم کدی که توی اون دکمه نوشتم.
    loading_img.Visible = true;

    // get the connection string from the config file
    ConnectionStringSettings connStringSettings
    = ConfigurationManager.ConnectionStrings["HealthConnection"];

    // create the connection object
    SqlConnection myConnection
    = new SqlConnection(connStringSettings.ConnectionString) ;

    // create the SqlDataAdapter
    SqlDataAdapter myAdapter = new SqlDataAdapter(
    "SELECT ID, fileNumber, firstName, lastName, nationalIssue FROM Person where fileNumber like '%" + fileNumber_txt.Text.Trim() + "%' and firstName like '%" + firstName_txt.Text.Trim().Replace("ی", "ي") + "%' and lastName like '%" + lastName_txt.Text.Trim().Replace("ی", "ي") + "%' and nationalIssue like '%" + nationalIssue_txt.Text.Trim() + "%'", myConnection);

    // create the command builder
    SqlCommandBuilder myCommandBuilder = new SqlCommandBuilder(myAdapter);

    // create the DataSet object
    DataSet myDataSet = new DataSet();

    // fill the dataset into the named table
    myAdapter.Fill(myDataSet, "Person");
    table.DataSource = myDataSet.Tables["Person"];

    counter_lbl.Text = table.RowCount.ToString();
    table.Columns[0].Visible = false;
    table.Columns[1].HeaderText = "شماره پرونده";
    table.Columns[2].HeaderText = "نام";
    table.Columns[3].HeaderText = "نام خانوادگی";
    table.Columns[4].HeaderText = "شماره ملی";

    table.Visible = true;
    loading_img.Visible = false;

    myConnection.Close();


    قست Details هم اینو می گه :

    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.NullReferenceException: Object reference not set to an instance of an object.
    at Health.Frm_Again.search_btn_Click(Object sender, EventArgs e)
    at System.Windows.Forms.Control.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ButtonBase.WndProc(Message& m)
    at System.Windows.Forms.Button.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


    ************** Loaded Assemblies **************
    mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
    ----------------------------------------
    Health
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Program%20Files/Coffeenet%20Aseman/Health/Health.exe
    ----------------------------------------
    System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
    ----------------------------------------
    System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    System.Data
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
    ----------------------------------------
    System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
    ----------------------------------------

    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.

    For example:

    <configuration>
    <system.windows.forms jitDebugging="true" />
    </configuration>

    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.

    آخرین ویرایش به وسیله sherlukholmz : سه شنبه 16 فروردین 1390 در 16:48 عصر

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •