User Defined Sql Function and ADO.Net

  • Thread starter Thread starter William Oliveri
  • Start date Start date
W

William Oliveri

Hi all,

Does anyone know the syntax for returning a value from a user defined
function in Sql Server using VB.Net.

Each time I do it I get:

invalid object name

We have a function which takes one parameter and returns a table.

I can find little or no documents directly addressing this subject.


Thanks in advance,

Bill
 
Are you qualifying that function name with the owner? dbo.DateFunction_DT
instead of DateFunction_DT That can be a problem.

HTH,

Bill
 
William Oliveri said:
Hi all,

Does anyone know the syntax for returning a value from a user defined
function in Sql Server using VB.Net.

Each time I do it I get:

invalid object name

We have a function which takes one parameter and returns a table.

I can find little or no documents directly addressing this subject.

This can be done. But here's a general rule: When in doubt, write your own
batch.

Run it it Query Analyzer, something like

declare @input1 varchar(50)
declare @rv int
set @rv = dbo.MyFunc(@input1)

Then use this in a command (CommandType.Text)

Then remove the declare's and attach SqlParameters to @rv
(ParameterDirection.Output) and @input1 (ParameterDirection.Input).

This works for stored procedures, functions, and arbitrary SQL.


Then if you want to get it running with CommandType.StoredProcedure, you at
least have someplace to start from.

David
 
Back
Top