Solved

How to call a function in SQL command

Posted on 2004-10-07
5
2,730 Views
Last Modified: 2008-01-09
Hi, I have a problem in creating a SQL command in VB DataEnvironment.
I created a following SQL command:
Select dimension(CategoryType,NL,A) as T from tblMyStock

Function Dimension is stored in Module. Example:
Public Function Dimension(CategoryType, NL, A)
Select Case CategoryType      
    Case "KSN"
    Dimension = NL * A
End Select
End Function

My question is, is it possible that SQL command call the function Dimension in Visual Basic 6?
previously i'm using MS Access 2000 and there is no problem on it.
Please assist.
Thank you very much.
0
Comment
Question by:william43
  • 2
5 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 12247548
Sorry, I don't use the DataEnvironment so I can't answer the question directly.  If it allows you to build the SQL command by concatenating strings, then you can create a  work around.  Something like:

    MySQLCmd = "Select " & Dimension(CategoryType,NL,A) & " as T from tblMyStock"
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 12253251
>>is it possible that SQL command call the function Dimension in Visual Basic 6?

The simple answer is no.

What kind of database are you useing and why would you want to do this?

Leon
0
 

Author Comment

by:william43
ID: 12273748
Hi Leon,
my database is MS Access 2000.
I'm wondering why Access can call a function in query but why not in VB? both products are from same "family" - microsoft's product.
anywhere, i will figure out another solution by using coding.
thanks guys.
0
 
LVL 29

Accepted Solution

by:
leonstryker earned 500 total points
ID: 12273812
Even though it is the same family of products, it is a very different thing.  The thing is Access can do this, but SQL Server and VB can not.  There are ways that you can kick off an executable from SQL but you can not call a function from SQL.

You may be able to do something however, you should launch the application from DTS or VB fire one procedure to a point then run the code in VB then pass things back to the SQL.  Or, you can try to recode the function in SQL.  What is your function trying to do?

Leon
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question