Solved

How to call a function in SQL command

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Share codes 68 114
Excel Spreadsheet - Send email if certain value is selected. 14 79
VB6 Compile Compatibility Issue 4 31
VBA filters 2 38
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now