SQL Query Help

Discussion in 'Microsoft ADO .NET' started by Tom Nowak, Apr 7, 2009.

  1. Tom Nowak

    Tom Nowak Guest

    I have an ASP.NET Web application that I want to write a query or stored
    procedure for.

    I want to get the results from two tables. One result set will contain all
    the names in one table. The second result set will contain some names from a
    second table. Then, I want to display the names that are in the first table
    that are NOT in the second table.

    Any suggestions would be appreciated.
     
    Tom Nowak, Apr 7, 2009
    #1
    1. Advertisements

  2. Tom Nowak

    sloan Guest

    You need to report your framework version.
    2.0/3.0 3.5 1.1?

    Very different answers depending.


    "Tom Nowak" <> wrote in message
    news:...
    >I have an ASP.NET Web application that I want to write a query or stored
    > procedure for.
    >
    > I want to get the results from two tables. One result set will contain
    > all
    > the names in one table. The second result set will contain some names
    > from a
    > second table. Then, I want to display the names that are in the first
    > table
    > that are NOT in the second table.
    >
    > Any suggestions would be appreciated.
     
    sloan, Apr 7, 2009
    #2
    1. Advertisements

  3. Tom Nowak

    Tom Nowak Guest

    Sorry.

    Visual Web Developer 2005 Express.

    Framework version 2.0


    "sloan" wrote:

    > You need to report your framework version.
    > 2.0/3.0 3.5 1.1?
    >
    > Very different answers depending.
    >
    >
    > "Tom Nowak" <> wrote in message
    > news:...
    > >I have an ASP.NET Web application that I want to write a query or stored
    > > procedure for.
    > >
    > > I want to get the results from two tables. One result set will contain
    > > all
    > > the names in one table. The second result set will contain some names
    > > from a
    > > second table. Then, I want to display the names that are in the first
    > > table
    > > that are NOT in the second table.
    > >
    > > Any suggestions would be appreciated.

    >
    >
    >
     
    Tom Nowak, Apr 7, 2009
    #3
  4. Tom Nowak

    sloan Guest

    I would get an IDataReader with 2 result sets.


    Make a strong DataSet or a CustomObject, CustomBusinessCollection.

    Let's say its employees.


    List<Employee> allEmps = new List<Employee>();

    //populate allEmps with first resultset from IDataReader

    .......

    List<Employee> coolEmps = new List<Employee>();
    //populate coolEmps with first resultset from IDataReader


    Write a "filter" then loop over allEmps...try to find a match in
    coolEmps....
    if no match, then add it to
    List<Employee> unCoolEmps = new List<Employee>();



    http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!140.entry

    You can find examples there in the project.

    CustomerFilter
    CustomerController.SerializeCustomers(method)
    will show you how to use the filter.

    In the example, I'm using the filter so I can add Order(s) to a specific
    Customer's list of Orders.


    ........

    You can write a "not exists" clause in TSQL, but then you're hitting the db
    3 times for stuff you can figure out with 2 db hits.
    Which I would choose last.



    With some good TSQL, you can maybe get the cool list and uncool listh with
    one hit.

    Let's pretend Germans are cool.

    Use Northwind

    GO

    select

    CustomerID ,

    CompanyName ,

    Country ,

    --[IsGerman] =

    [IsCool] =

    CASE

    WHEN Country like '%Germany%' then 1

    else 0

    END

    from dbo.Customers















    "Tom Nowak" <> wrote in message
    news:...
    > Sorry.
    >
    > Visual Web Developer 2005 Express.
    >
    > Framework version 2.0
    >
    >
    > "sloan" wrote:
    >
    >> You need to report your framework version.
    >> 2.0/3.0 3.5 1.1?
    >>
    >> Very different answers depending.
    >>
    >>
    >> "Tom Nowak" <> wrote in message
    >> news:...
    >> >I have an ASP.NET Web application that I want to write a query or stored
    >> > procedure for.
    >> >
    >> > I want to get the results from two tables. One result set will contain
    >> > all
    >> > the names in one table. The second result set will contain some names
    >> > from a
    >> > second table. Then, I want to display the names that are in the first
    >> > table
    >> > that are NOT in the second table.
    >> >
    >> > Any suggestions would be appreciated.

    >>
    >>
    >>
     
    sloan, Apr 7, 2009
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Glenn Nilsson

    how to query a dataset or datatable with a sql-query?

    Glenn Nilsson, Oct 9, 2003, in forum: Microsoft ADO .NET
    Replies:
    5
    Views:
    1,757
  2. Eva

    SQL query help

    Eva, Oct 31, 2003, in forum: Microsoft ADO .NET
    Replies:
    4
    Views:
    190
  3. Guest

    Help on developing a SQL Query tool in ASP.NET

    Guest, Feb 6, 2004, in forum: Microsoft ADO .NET
    Replies:
    0
    Views:
    178
    Guest
    Feb 6, 2004
  4. Guest

    Help developing a SQL Query tool

    Guest, Feb 9, 2004, in forum: Microsoft ADO .NET
    Replies:
    1
    Views:
    172
    William Ryan eMVP
    Feb 9, 2004
  5. rob willaar

    SQL Query help

    rob willaar, Aug 27, 2004, in forum: Microsoft ADO .NET
    Replies:
    3
    Views:
    152
    rob willaar
    Aug 27, 2004
Loading...

Share This Page