Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 30th, 2004, 03:55 PM
Authorized User
 
Join Date: Jun 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Raif
Default Call query from a query

Hi, first let just state that I'm hanging on by my teeth so bear with me.
I am trying to convert or reright an Access db in asp.net using sqlserver
in my access code I create a qry and then create another qry that calls data from the first qry.

In asp.net I create a function that calls a dataset and binds it to a data grid. that works fine. so next I created an other function and in the sql string I included the name of the function that created the first qry. So it looks something like this with the ending parts left off for space.

public Function qryIndTotals() As System.Data.IDataReader

        Dim queryString As String = "SELECT [tblSlots].[pkDate], " _
        & " Count([tblSlots].[slot1trainer]) AS [CountOfTrainerSlot1], " _
        & " Count([tblSlots].[slot2trainer]) AS [CountOfTrainerSlot2]," _
        &" Count([tblSlots].[slot3trainer]) AS [CountOfTrainerSlot3]" _
        & "FROM [tblSlots] GROUP BY [tblSlots].[pkdate]"

This one binds fine
Then I try

 Function qryWeekSum() as system.data.idatareader
        dim qryString as string = "SELECT [qryIndTotals].*, [qryIndTotals].[CountOfTrainerSlot1].[qryIndTotals].[CountOfTrainerSlot2]+[qryIndTotals].[CountOfTrainerSlot3] " _
        & " AS Total FROM [qryIndTotals] "

(sorry for the messy formating)
anyway I get "invalid obj name"

Now I'm not nieve ;) it doesn't supprise me that it doesn't work but if someone could walk me through the correct way I would be very greatful
Thanks very much
Raif
[email protected]

 
Old June 30th, 2004, 04:17 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can't do what you wrote. The .NET function can't be called by SQL.

It looks like all you are doing is totalling up results. Can you just iterate through the rows of the result from the first function and total up the values?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Call to a member function query() on a non-object Boszky Pro PHP 0 November 15th, 2007 09:37 AM
how to call xml using javascript then query Apocolypse2005 Javascript 0 January 11th, 2006 10:53 AM
Sql Query call does not work. mikehsu317 C# 0 September 26th, 2005 11:15 AM
call resultset in join query zaman1111 JSP Basics 2 November 5th, 2004 08:44 AM
Using a Pass-Through Query to call an Oracle SP Richelou Access VBA 1 September 17th, 2004 04:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.