English 中文(简体)
2. 退约
原标题:Returning a null Reference Exception
  • 时间:2011-02-24 09:23:18
  •  标签:
  • c#
  • subsonic
 public void SchemeUpdate(int SchemeID, int InsurerID, string Name, string Description)
        {
            Health_Scheme_System.Scheme updscheme = Scheme.Find(x => x.SchemeID == SchemeID).FirstOrDefault();

            //updscheme.SchemeID = SchemeID;
            //updscheme.InsurerID = InsurerID;
            updscheme.Name = Name;
            updscheme.Description = Description;                             
            updscheme.Save();
}


Calling the method


  //Converting to integer and date
                    int SchemeID;
                    int.TryParse(txtSchemeID.Text, out SchemeID);

                    int insurerID;
                    int.TryParse(txtInsurerID.Text, out insurerID);


                    //Getting the parameters from the method
                    DataAccess updscheme = new DataAccess();
                    //DataAccess updrates = new DataAccess();
                    updscheme.SchemeUpdate(SchemeID, insurerID, txtName.Text, txtDescription.Text);
                    //updrates.RatesUpdate(SchemeID, txtRates.Text);

                    //Binding the gridView to display the updates
                    txtSchemeID.Visible = false;
                    txtInsurerID.Visible = false;
                    gvSchemeMain.DataSource = ds.GetRates();
                    gvSchemeMain.DataBind();

我认为,这些问题与参数有关。

问题回答

根据你的意见,它看上去了这一行文:

Health_Scheme_System.Scheme updscheme = Scheme.Find(x => x.SchemeID == SchemeID).FirstOrDefault();

不是归还任何东西。 换言之,没有发现你重新使用的任何办法。

可在数据库中人工核对<代码>Scheme,并获取其识别价值。 然后,你可以通过将这一价值并入普惠制参数来测试上述代码。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签