Solved

How to call a function in SQL command

Posted on 2004-10-07
5
2,731 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 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…

856 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