Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a UDF using ADO 2

Status
Not open for further replies.

gradley

Programmer
Feb 24, 2004
335
US
Has anyone tried calling a SQL Server 2000 User Defined Function (UDF) using the ADO object model? I would like to execute this function from within a VB6 application passing a couple of parameters and returning a char(1) value.

I have tried researching this through MSDN but had no success. I would hate to have to create a Stored Procedure to mimic this logic.

Any help would be appreciated.
 
You could create a stored procedure to simply call the UDF. You wouldn't have to duplicate the logic, just to refernce it.
 
I don't know whether you can call the function directly from the VB. But the easiest way I see is to execute a normal SQL query using the function and get the value back from the recordset:

Code:
Set oRS = oConn.Execute("SELECT dbo.my_func(" & intA & ", " & intB & ") AS the_answer")

strAnswer = oRS("the_answer")

--James
 
Both very good suggestions...

Thanks for the feedback.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top