0

when invoking an SQL functions by means of ADO.NET, is it allowed to set CommandType.StoredPRocedure? I know that the purpose of this enum is to specify a stored procedure; for functions CommandType.Text should be used. But I don't like writting some select statements (CommandText = "SELECT foo FROM dbo.Goo") in .NET code.

Thanx

llasarov
  • 2,064
  • 5
  • 27
  • 40

1 Answers1

0

Yes, it should work. Basically you should :

  • define a parameter with Direction = ParameterDirection.ReturnValue to fetch the result
  • call ExecuteNonScalar

See this post from GSerg for an example :

ExecuteScalar always returns null when calling a scalar-valued function

Community
  • 1
  • 1
Moe Sisko
  • 11,665
  • 8
  • 50
  • 80