Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to call a function in SQL command

Posted on 2004-10-07
5
Medium Priority
?
2,740 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
4 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 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

810 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