title: Call SQL Function using ADO .NET
body: <p>I want call function created in SQL Server, which receives two parameters and returns an integer. When I call stored procedure, I use the following code:</p>
  
  <pre><code>    sqlcmd.CommandType = CommandType.StoredProcedure
      sqlcmd.CommandText = "PROCEDURE_NAME"
  
      sqlcmd.Parameters.Add(New SqlClient.SqlParameter("@param1", Utilities.NothingToDBNull(user)))
      sqlcmd.Parameters.Add(New SqlClient.SqlParameter("@param2", Utilities.NothingToDBNull(password)))
      da = New SqlClient.SqlDataAdapter()
      da.SelectCommand = sqlcmd
      table = New DataTable()
      da.Fill(table)
  </code></pre>
  
  <p>In this case I have a table returned by the stored procedure. What changes if I want use a function that returns a scalar value instead of stored procedure?</p>