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)...
The following error is raised when my code populates the DataTable (via the DataAdapter's SelectCommand):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 GetAssetPrice function works in my VB.Net application. For example:
A similar query works in MS Access:Code:Debug.Print(GetAssetPrice(20, Date.Now, "ClosePrice").ToString)
I don't know why it doesn't work in my VB.Net SelectData statement.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'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?




Reply With Quote
