Output parameter type 'DATETIME' is not a valid SQL type

8 posts, 0 answers
  1. Tony Girling
    Tony Girling avatar
    2 posts
    Member since:
    Nov 2009

    Posted 26 Feb 2010 Link to this post

    I have a stored procedure that returns a DateTime result in an output parameter named 'weekEnding'.
    The code I'm using to get the result is...
     
    using (var scope = GetNewObjectScope()) 
                { 
                    // Humm!! following throws exception on Execute --- "Param type 'DATETIME' is not a valid SQL type." 
                    var query = scope.GetSqlQuery("Common.DetermineCurrentActualsWeekEnding ?", null, "out.datetime weekEnding"); 
                    var queryqueryResult = query.Execute(null); 
                    reportWeek = (DateTime)queryResult.OutParameter["weekEnding"]; 
                } 

    When I run the code I get a runtime exception:-
    Telerik.OpenAccess.OpenAccessException.Failure.Internal, reason; "Param type 'DATETIME' is not a valid SQL type."

    Ideas?
    Tony.

  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 04 Mar 2010 Link to this post

    Hello Tony Girling,

    You should not use datetime but timestamp when you are defining the parameters. Having this in mind, your code would look like this:
    using (var scope = GetNewObjectScope())
                {
                    // Humm!! following throws exception on Execute --- "Param type 'DATETIME' is not a valid SQL type."
                    var query = scope.GetSqlQuery("Common.DetermineCurrentActualsWeekEnding ?", null, "out.timestamp weekEnding");
                    var queryqueryResult = query.Execute(null);
                    reportWeek = (DateTime)queryResult.OutParameter["weekEnding"];
                }
    Hope that helps.

    Sincerely yours,
    Petar
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. Tony Girling
    Tony Girling avatar
    2 posts
    Member since:
    Nov 2009

    Posted 08 Mar 2010 Link to this post

    Petar,

    Thanks for your reply.  I didn't spot the TIMESTAMP type.

    But my query still fails (ignoring the obvious typo in the code example; query typed twice in queryqueryResult).

    The GetSqlQuery result has 'query.BackendQuery' threw an exception of type 'Telerik.OpenAccess.Exceptions.InvalidOperationException. Base message:- {"Expected 1 parameters, have 0"}



    The stored proc takes no input parameters and only has one output parameter (the TIMESTAMP).

    I'm clearly not building the query correctly but cannot find an example or documentation that shows me how.

    Any pointers accepted.




    Cheers,
    Tony.
  5. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 11 Mar 2010 Link to this post

    Hello Tony Girling,

    You will have to pass a parameter regardless of the fact that it will not be used. The parameter value will be replaced with the value from the SQL server. So changing your code to something similar to this should do the trick:
    scope.GetSqlQuery("Common.DetermineCurrentActualsWeekEnding ?", null, "out.timestamp weekEnding");
                    var queryqueryResult = query.Execute(DateTime.Now);
                    reportWeek = (DateTime)queryResult.OutParameter["weekEnding"];


    Greetings,
    Petar
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. Bruno Michels
    Bruno Michels avatar
    3 posts
    Member since:
    Apr 2010

    Posted 04 May 2010 Link to this post

    What are the types supported by Telerik.OpenAccess?
  7. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 04 May 2010 Link to this post

    Hi Bruno Michels,

    A list of all the available types can be found in our online documentation. Please note that the same documentation is available in a chm format that is distributed with our product. I hope that helps.

    Best wishes,
    Petar
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  8. Bruno Michels
    Bruno Michels avatar
    3 posts
    Member since:
    Apr 2010

    Posted 04 May 2010 Link to this post

    That was helpful, thanks.
  9. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 05 May 2010 Link to this post

    Hi Bruno Michels,

    We are happy that we could assist you. If you face any further difficulties please do not hesitate to contact us.

    Regards,
    Petar
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
DevCraft banner