• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 749
  • Last Modified:

call SqlServer scalar function from .NET

I know how to call stored procedures from VB.NET, but is there a way to call Scalar Functions from .NET code? WOuld this work, even though I am calling a function and not a procedure?

            Dim cn As New SqlConnection("server=.\ddb;database=SFS;integrated security = true")

            Dim cmd As New SqlCommand("monthsForPivot", cn)
            'Dim cmd As New SqlCommand("make_fundingNew_05_dynamic_grossCenter", cn)
            cmd.CommandType = CommandType.StoredProcedure

            cmd.Parameters.AddWithValue("@endMonth", "200512")
            cmd.Parameters.AddWithValue("@format", "MTH")

1 Solution
Éric MoreauSenior .Net ConsultantCommented:
Call it using a SQL Select statement:

select dbo.make_fundingNew_05_dynamic_grossCenter(200512, 'MTH')
brokeMyLegBikingAuthor Commented:
ha! very simple, very good.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now