9

the code below keeps throwing an exception throw new NotImplementedException() and I m am not sure how to fix it. I am trying to capture the datetime returned by the stored procedure below.

public void FormCarry_Load(object sender, EventArgs e)
{
    System.DateTime? test;
    test = new System.DateTime(2013, 04, 22);

    //    spMaxDateinGreeks test2 = new spMaxDateinGreeks();

    test = (DateTime)spMaxDateinGreeks(ref test);

    monthCalendarAdv1.Value = test.Value;
    monthCalendarAdv1.Value = new System.DateTime(2013, 04, 22); 
}

private DateTime spMaxDateinGreeks(ref DateTime? test)
{
    throw new NotImplementedException();
}

ALTER PROCEDURE [dbo].[spMaxDateinGreeks] (@returneddate datetime OUTPUT)
--spMaxDateinGreeks null

AS
SET NOCOUNT ON;
--if @InqDate is null
Select @returneddate= max(valuationdate) 
 from Greeks

 RETURN

EDIT: @Sam This is what's implemented by the designer

 public virtual int spMaxDateinGreeks(ref global::System.Nullable<global::System.DateTime> returneddate) {
            global::System.Data.SqlClient.SqlCommand command = ((global::System.Data.SqlClient.SqlCommand)(this.CommandCollection[0]));
            if ((returneddate.HasValue == true)) {
                command.Parameters[1].Value = ((System.DateTime)(returneddate.Value));
            }
            else {
                command.Parameters[1].Value = global::System.DBNull.Value;
            }
            global::System.Data.ConnectionState previousConnectionState = command.Connection.State;
            if (((command.Connection.State & global::System.Data.ConnectionState.Open) 
                        != global::System.Data.ConnectionState.Open)) {
                command.Connection.Open();
            }
            int returnValue;
            try {
                returnValue = command.ExecuteNonQuery();
            }
            finally {
                if ((previousConnectionState == global::System.Data.ConnectionState.Closed)) {
                    command.Connection.Close();
                }
            }
            if (((command.Parameters[1].Value == null) 
                        || (command.Parameters[1].Value.GetType() == typeof(global::System.DBNull)))) {
                returneddate = new global::System.Nullable<global::System.DateTime>();
            }
            else {
                returneddate = new global::System.Nullable<global::System.DateTime>(((global::System.DateTime)(command.Parameters[1].Value)));
            }
            return returnValue;
        }
user2321650
  • 157
  • 1
  • 1
  • 8

1 Answers1

63

It's right there in your code

private DateTime spMaxDateinGreeks(ref DateTime? test)
{
    throw new NotImplementedException();
}

It means exactly what it says, Your method is not implemented yet. It doesn't do anything. It's only there as a placeholder.

You should either implement spMaxDateinGreeks, or stop calling it.

  • Sam, I used the O/R designer to create this and I thought the implementation was automatic in that case. Is it not? – user2321650 Apr 30 '13 at 15:42
  • 4
    @user2321650 no, it's not. All you have really is the signature of the method It's expecting you to write the actual content of the method. – Sam I am says Reinstate Monica Apr 30 '13 at 15:43
  • 1
    @user2321650 What “O/R designer” are you talking about? – svick Apr 30 '13 at 15:45
  • @user2321650 or maybe it will implement it automatically, and It just hasn't yet. Is the code you've posted your own code? or is it automatically-generated designer code? – Sam I am says Reinstate Monica Apr 30 '13 at 15:48
  • @ svick :Visual Studio provides an object-relational mapping designer, called the O/R Designer, which allows you to visually design the object to database mapping. – user2321650 Apr 30 '13 at 15:54
  • fyi I was using http://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx as a guide. – user2321650 Apr 30 '13 at 16:02
  • @user2321650 Does that mean I can assume the the code you're originally posted is not actually designer code? – Sam I am says Reinstate Monica Apr 30 '13 at 16:17
  • 1
    Never mind I am going to use a different approach. Returning a value from a stored procedure in LINQ is troublesome. Thanks even though it didn't solve my main issue, you answered the question at hand. – user2321650 Apr 30 '13 at 16:44
  • The [.Net documentation](https://learn.microsoft.com/en-us/dotnet/api/system.notimplementedexception?view=netframework-4.8) says _a NotImplementedException exception should be synonymous with "still in development."_ – openshac Mar 10 '20 at 15:10