?
Solved

How to call a function in SQL command

Posted on 2004-10-07
5
Medium Priority
?
2,736 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

765 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