Results 1 to 9 of 9

Thread: Executing SQL FUNCTION

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Santo Domingo,D.N., Dom. Rep.
    Posts
    707

    Talking Executing SQL FUNCTION

    If i wrote my function on a SQL SERVER (on User Defined Functions on the Database). How can i call from My VB project and how could i pass parameters?

  2. #2
    Fanatic Member
    Join Date
    May 2002
    Posts
    746
    function as stored procedure?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Santo Domingo,D.N., Dom. Rep.
    Posts
    707
    A Function.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Santo Domingo,D.N., Dom. Rep.
    Posts
    707
    Sorry. Not store procedure as function. A user defined function, saved on this folder on the database.

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    I don't think ADO can call functions directly... (but I could be wrong)... but you could use a stored procedure as a "wrapper" to calling the function.
    So, it would work like this app (using ADO) calls the stored procedure, which calls the function.... parameters would be passed to the stored proc which would pass them to the function, and the result would then get passed back through an output parameter...
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    Fanatic Member
    Join Date
    May 2002
    Posts
    746
    I've never heard of such a thing. Which doesn't really mean anything. Good luck.

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by Briantcva
    I've never heard of such a thing. Which doesn't really mean anything. Good luck.
    Starting w/ SQL2000, you can create Functions which can return a sincgle value (scalar) or a table (table function).... these are neat in that they can be used as part of a larger SQL statement, the way you can include a view, but they are better than a view because you can pass parameters to them, like a stored proc.
    Normally you can't join to a stored proc or use the return value of a stored proc as a field in a select, so MS created UDFs, USer Defined Functions..... we've found then quite handy and wonderfull.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8
    Fanatic Member
    Join Date
    May 2002
    Posts
    746
    And now I feel better and not having heard of them (running NT and SQL 7). Very cool. Thanks.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Santo Domingo,D.N., Dom. Rep.
    Posts
    707

    Talking RESOLVED

    sqlstring = "Select top 1 suscripcion.dbo.ultimo_dia_del_mes(" & CVar(fecha) & ") from parametros "
    Dim rs As New ADODB.Recordset
    Set rs = New ADODB.Recordset
    rs.Open sqlstring, cn, adOpenForwardOnly, adLockReadOnly
    x = rs.Fields(0)

    Where
    suscripcion.dbo=Database
    ultimo_dia_del_mes=Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width