Results 1 to 12 of 12

Thread: Undefined function in query

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2013
    Location
    San Francisco, CA
    Posts
    528

    Undefined function in query

    I've got a DataAdapter that I'm using to load a DataTable. I've configured the DataAdpater's SelectCommand as follows (note the "GetAssetPrice" function that is embedded in the SELECT statement)...

    Code:
    Dim selectData As New OleDb.OleDbCommand("SELECT Accounts.AccountName, Assets.AssetSymbol, Assets.AssetName, GetAssetPrice(Assets.RecID, #" & Date.Today & "#, ""ClosePrice"") AS AssetPrice, Positions.* " & _
                                                     "FROM Assets INNER JOIN (Accounts INNER JOIN Positions ON Accounts.RecID = Positions.AccountID) ON Assets.RecID = Positions.AssetID " & _
                                                     "ORDER BY Accounts.AccountName, Assets.AssetName", con)
    
    daPositions.SelectCommand = selectData
    The following error is raised when my code populates the DataTable (via the DataAdapter's SelectCommand):

    Name:  2019-04-18_19-32-36.jpg
Views: 830
Size:  27.7 KB

    The GetAssetPrice function works in my VB.Net application. For example:

    Code:
    Debug.Print(GetAssetPrice(20, Date.Now, "ClosePrice").ToString)
    A similar query works in MS Access:

    Code:
    SELECT Accounts.AccountName, Assets.AssetSymbol, Assets.AssetName, GetAssetPrice([Assets].[RecID],Now(),'ClosePrice') AS AssetPrice, [AssetPrice]*[Positions].[PositionShares] AS PositionBalance, Positions.*
    FROM Assets INNER JOIN (Accounts INNER JOIN Positions ON Accounts.RecID = Positions.AccountID) ON Assets.RecID = Positions.AssetID
    WHERE (((Accounts.RecID)=20));
    I don't know why it doesn't work in my VB.Net SelectData statement.

    I've been looking at this for a couple of hours and I'm stuck...can someone please point me in the right direction to fix this error?
    Last edited by Mark@SF; Apr 18th, 2019 at 10:36 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width