How to call User Defined Function Thru VB

I have created User Defined Function(UDF) in MS SQL SERVER and want to call it thru vb. Foll is the function :
CREATE FUNCTION fn_Major ()
RETURNS Int AS  
BEGIN
return (5)
END

After i execute this fn in VB i want the return value ie;5
tr_pradeepAsked:
Who is Participating?
 
TimCotteeConnect With a Mentor Commented:
Hi tr_pradeep,

To return the value of the function you simple need to use whichever data access method you currently use (DAO or ADO) to execute a select statement of the form:

Select dbo.fn_Major()

And you will get a value of 5 in the first element of the returned fields collection.

Tim Cottee MCSD, MCDBA, CPIM
http://www.timcottee.tk 

Brainbench MVP for Visual Basic
http://www.brainbench.com

Experts-Exchange Advisory Board Member
0
 
CleanupPingCommented:
tr_pradeep:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
DanRollinsCommented:
Moderator, my recommended disposition is:

    Accept TimCottee's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0
All Courses

From novice to tech pro — start learning today.