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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call function using ODBC connection 1

Status
Not open for further replies.

Baesucks

Programmer
Mar 10, 2008
37
US
I have an ODBC connection object to a SQL Server in my vba code (which I believe is functioning OK). I want to execute a user defined function on the server using that connnection and store the result in a variable in my vba code. I'm not sure what the syntax is...

Code:
Dim wrkODBC As Workspace
Dim conOdbc As Connection
Dim functionResult As String

Set wrkODBC = CreateWorkspace "NewODBCWorkspace", "admin", "", dbUseODBC)
Set conOdbc = wrkODBC.OpenConnection("Cascade_PICS", 
dbDriverNoPrompt, True, "ODBC;DATABASE=Thrombo_PiCS;DSN=Cascade_PICS")

'?????? here is something like I would expect I'm trying to do
functionResult = conOdbc.Execute("myfunction(25)")
 
Code:
dim rst as recordset

Set rst= conOdbc .Execute ("Select dbo.functionname() as functionResult ")

functionResult =rst!functionResult
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top