CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Posts
    97

    Unhappy DataTable and SQL Queries

    Is there an method or a way of preforming a SQL SELECT statement on a DataTable so that it returns a array of Rows?

    The DataTable.Select() method won't do the job as my query is a bit too complex for me to use it.

    This is my SQL query:

    SELECT COUNTY_ID , NAME
    FROM TOWNS
    WHERE NAME IN
    ( SELECT NAME FROM TOWNS
    GROUP BY NAME HAVING COUNT(*) > 1);

    Do I need to use a SQLDataAdapter or something? Just a guideline on how I should go about doing this would be helpful.

    Thanks

  2. #2
    Join Date
    Nov 2002
    Location
    Tatooine
    Posts
    155
    You could try using a SqlDataReader that is returned from the SqlCommand.ExecuteReader method.

    Hope this helps.
    That which does not kill us, only makes us stronger.

    MCSD .NET

  3. #3
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    check SqlDataReader for more information.

    SqlDataReader d;
    // blah blah
    // declaration and usage of d
    object []a = new object[..]
    d.GetValues(a);

    Paresh
    - Software Architect

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

Featured