Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# System.NotImplementedException错误_C# - Fatal编程技术网

C# System.NotImplementedException错误

C# System.NotImplementedException错误,c#,C#,我正在使用ASP.NET3.5。我制作了一个表单,当用户点击一个按钮时,它应该在另一个页面上添加信息。我没有加载,而是得到以下错误页面: The method or operation is not implemented. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more inf

我正在使用ASP.NET3.5。我制作了一个表单,当用户点击一个按钮时,它应该在另一个页面上添加信息。我没有加载,而是得到以下错误页面:

The method or operation is not implemented. 
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.NotImplementedException: The method or operation is not implemented.

Source Error: 

    public static dsPersonnel GetPersonnel(string p)
    {
       throw new NotImplementedException();
    } 

Source File:    Line: 203 
我不确定为了提供足够的帮助信息,我需要在这里发布什么

下面是可能出现错误的代码。我想我可能有点不对劲:

    public clsDataLayer()
    {

    }

    // This function gets the user activity from the tblPersonnel
    public static dsPersonnel GetPersonnel(string Database, string strSearch)
    {
        dsPersonnel DS;
        OleDbConnection sqlConn;
        OleDbDataAdapter sqlDA;

        //create the connection string 
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
        "Data Source=" + Database);

        string query;
        if (strSearch == "" || strSearch.Trim().Length == 0)
        {
            query = "SELECT * from tblPersonnel";
        }
        else
        {
            query = "select * from tblPersonnel where LastName = '" + strSearch + "'";
        }


        // Defines sqlDA and what each will consist of
        sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);

        // Defines DS and what each will consist of
        DS = new dsPersonnel();

        // Outputs the results from the information gathered
        sqlDA.Fill(DS.tblPersonnel);

        // Starts over for a new user
        return DS;
    }

    // This function saves the user activity
    public static void SavePersonnel(string Database, string FormAccessed)
    {
        // Defines the connection to the database
        OleDbConnection conn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
            "Data Source=" + Database);
        conn.Open();
        OleDbCommand command = conn.CreateCommand();
        string strSQL;

        strSQL = "Insert into tblPersonnel (UserIP, FormAccessed) values ('" +
            GetIP4Address() + "', '" + FormAccessed + "')";

        command.CommandType = CommandType.Text;
        command.CommandText = strSQL;
        command.ExecuteNonQuery();
        conn.Close();

    }

    public static dsPersonnel GetPersonnel(string p)
    {
        throw new NotImplementedException();
    }
}

此错误意味着您正在加载的页面未实现GetPersonal方法,该方法在加载过程中由其代码访问。我认为您应该检查正在加载的页面的源代码,并实现此方法。

您正在调用的特定方法(考虑到它不是类库方法)很可能专门执行以下操作:

 throw new NotImplementedException();

现在是存根。这是解决方案中的代码;因此,在您的页面上,您的方法可能没有实现

这正是错误所说的。您有一行代码抛出一个未实现的异常。看这里:


第201行:公共静态dspersonal getpersonal(字符串p)第202行:{203行:抛出新的NotImplementedException();204行:}205行:}

您或其他人可能已经添加了
getpersonal()
方法,该方法使用Visual Studio自动代码生成技术,在代码中插入
NotImplementedException
行,您必须手动删除它


在您的
getPersonal()
方法中,删除
抛出新的NotImplementedException
。。。行,并完全实现该方法以返回与该方法的返回类型匹配的值。

对于初学者,请尝试在下面的代码中注释或删除该段代码

   throw new NotImplementedException();

如果您不知道应该返回什么,只需注释那段代码即可

抛出新的NotImplementedException()

并将其替换为


返回0

您是否实现了GetPersonal方法?默认情况下,存根将抛出NotImplementedException,直到您实际实现该方法。你说要实现这个方法。我想已经是了。如果删除throw new NotImplementedException()语句,则会出现许多其他错误。这就是为什么我觉得我有点不对劲了。其中一个重载方法未实现,页面加载时可能会调用该方法,请实现它。。!!