How to get the number of retrieved columns when doing a SQL Query

Discussion in 'ASP .Net Datagrid Control' started by Roman Klimkowicz, Sep 15, 2005.

  1. Hello everyone,

    i just implement an own search site in MS CRM 1.2, which searches in a
    MS-SQL database.

    My question is, how to get the number of retrieved columns by a SQL-query??

    Any suggestions for me?

    Thx...


    Greets,

    Roman
     
    Roman Klimkowicz, Sep 15, 2005
    #1
    1. Advertising

  2. Roman Klimkowicz

    xianxian Guest

    hi,
    i only heard number of retrieved rows ..

    SELECT COUNT(column) FROM tablename

    but i never heard if u can count number of columns..
    isn't it like, as u do SQL query, u will already know what columns u are
    retrieving?

    why do u need to count the columns that u r retrieving when u already
    know the columns that u r going to retrieve?

    regards,
    xianxian

    *** Sent via Developersdex http://www.developersdex.com ***
     
    xianxian, Sep 16, 2005
    #2
    1. Advertising

  3. Roman Klimkowicz

    Romantschik Guest

    xianxian schrieb:
    > hi,
    > i only heard number of retrieved rows ..
    >
    > SELECT COUNT(column) FROM tablename
    >
    > but i never heard if u can count number of columns..
    > isn't it like, as u do SQL query, u will already know what columns u are
    > retrieving?
    >
    > why do u need to count the columns that u r retrieving when u already
    > know the columns that u r going to retrieve?
    >
    > regards,
    > xianxian
    >
    > *** Sent via Developersdex http://www.developersdex.com ***


    Sorry I did not mean column but the row :) - My fault .. too much work
    ;-)

    Anyway .. I know how to get the number of rows which where retrieved by
    firing a SQL-query in SQL code but I need a .NET Method oder workaround
    to read this value...

    Any suggestions?

    Sorry for the false description in my initial post.

    Greets,

    Roman
     
    Romantschik, Sep 16, 2005
    #3
  4. Roman Klimkowicz

    Sachin Saki Guest

    Re: How to get the number of retrieved columns when doing a SQL Qu

    Hi,

    Can you more specific to problem. so i can try to provide solution.

    Regards,
    Sachin Saki
    ..NET Developer, Capgemini - INDIA

    "Romantschik" wrote:

    > xianxian schrieb:
    > > hi,
    > > i only heard number of retrieved rows ..
    > >
    > > SELECT COUNT(column) FROM tablename
    > >
    > > but i never heard if u can count number of columns..
    > > isn't it like, as u do SQL query, u will already know what columns u are
    > > retrieving?
    > >
    > > why do u need to count the columns that u r retrieving when u already
    > > know the columns that u r going to retrieve?
    > >
    > > regards,
    > > xianxian
    > >
    > > *** Sent via Developersdex http://www.developersdex.com ***

    >
    > Sorry I did not mean column but the row :) - My fault .. too much work
    > ;-)
    >
    > Anyway .. I know how to get the number of rows which where retrieved by
    > firing a SQL-query in SQL code but I need a .NET Method oder workaround
    > to read this value...
    >
    > Any suggestions?
    >
    > Sorry for the false description in my initial post.
    >
    > Greets,
    >
    > Roman
    >
     
    Sachin Saki, Sep 16, 2005
    #4
  5. Roman Klimkowicz

    Elton Wang Guest

    If you retrieve your query result to a datatable, datatable.Rows.Count gives
    you row numbers.

    HTH

    "Romantschik" <> wrote in message
    news:u%23$h$...
    > xianxian schrieb:
    > > hi,
    > > i only heard number of retrieved rows ..
    > >
    > > SELECT COUNT(column) FROM tablename
    > >
    > > but i never heard if u can count number of columns..
    > > isn't it like, as u do SQL query, u will already know what columns u are
    > > retrieving?
    > >
    > > why do u need to count the columns that u r retrieving when u already
    > > know the columns that u r going to retrieve?
    > >
    > > regards,
    > > xianxian
    > >
    > > *** Sent via Developersdex http://www.developersdex.com ***

    >
    > Sorry I did not mean column but the row :) - My fault .. too much work
    > ;-)
    >
    > Anyway .. I know how to get the number of rows which where retrieved by
    > firing a SQL-query in SQL code but I need a .NET Method oder workaround
    > to read this value...
    >
    > Any suggestions?
    >
    > Sorry for the false description in my initial post.
    >
    > Greets,
    >
    > Roman
     
    Elton Wang, Sep 16, 2005
    #5
    1. Advertising

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. Simnet
    Replies:
    0
    Views:
    377
    Simnet
    Dec 3, 2004
  2. Replies:
    4
    Views:
    532
  3. Anonymous
    Replies:
    0
    Views:
    1,480
    Anonymous
    Oct 13, 2005
  4. Roman Klimkowicz

    How to the get to number of retrieved columns?

    Roman Klimkowicz, Sep 15, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    107
    Scott Mitchell [MVP]
    Sep 19, 2005
  5. Martin
    Replies:
    3
    Views:
    1,490
    Steven Cheng[MSFT]
    Oct 17, 2006
Loading...

Share This Page