0

My SQL Server 2012 contains a function Get_Schedule:

CREATE FUNCTION Get_Schedule(
    @pProject_Id   AS INT,
    @pPeriod_Start AS DATETIME2,
    @pPeriod_End   AS DATETIME2)
RETURNS TABLE
WITH SCHEMABINDING
AS
    RETURN (
        SELECT
            42     AS Val1,
            'Foo'  AS Val2);

Visual Studio 2015's SQL Server Object Explorer shows the function parameters with the types as defined.

However when dragging the function to the strongly typed dataset designer the DATETIME2 parameters are changed to ANSISTRING instead of System.DateTime or System.Data.SqlDbType.DateTime2.

The int parameter, @pProject_Id does have the correct type.

This happens both when using a select statement for the table adapter to access the database and when creating new a stored procedure (the procedure itself does have the expected DATATIME2 as parameter but the generated table adapter has ansistring).

How to have the correct parameter types in the generated table adapters?

1 Answer 1

2

After adding the query and its table adapter:

  • open the table adapter's properties;
  • expand SelectCommand; and,
  • edit the Parameters tot the correct type.
Sign up to request clarification or add additional context in comments.

1 Comment

Just a warning to anyone adopting this method (which works) - if you subsequently change your query it will regenerate the command and reset the parameters back to their defaults.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.