Using sqlDataAdapter to fill Dataset

Discussion in 'ASP .Net Datagrid Control' started by Andy G, Jan 31, 2005.

  1. Andy G

    Andy G Guest

    I am setting my adapter to the below value and then filling the dataset and
    binding the data grid to that after I set my dataset equal to the datagrid's
    datasource. I manual bind the fields of the query to the datagrid. Can I
    set my sqlDataAdapter like this. It's choking on B.QSTN fields but finds
    the first three. I SQL statement below works fine in my query analyzer.

    SELECT A.PRSN_ID, A.LOGIN_NAME, A.ANSWER, B.QSTN, C.DESCR FROM
    tblCFSPH_CM_LOGIN A INNER JOIN tblCFSPH_CM_PRSN_ROLE_LINK D ON A.PRSN_ID =
    D.PRSN_ID INNER JOIN tblCFSPH_CM_ROLE C ON D.ROLE_ID = C.ROLE_ID LEFT JOIN
    tblCFSPH_SECRT_QSTN B ON A.QSTN_ID = B.QSTN_ID

    Thanks!
     
    Andy G, Jan 31, 2005
    #1
    1. Advertising

  2. Andy G

    Elton Wang Guest

    Hi Andy,

    If you only want to bind the first three fields in the
    query to the datagrid, that's OK.

    Set datagrid's AutoGenerateColumns to False

    and set three BoundColumns in the datagrid like:

    <Columns>
    <asp:BoundColumn DataField="PRSN_ID" HeaderText="ID">
    </asp:BoundColumn>
    <asp:BoundColumn DataField="LOGIN_NAME"
    HeaderText="Name">
    </asp:BoundColumn>
    <asp:BoundColumn DataField="ANSWER" HeaderText="Answer">
    </asp:BoundColumn>
    </Columns>

    That will only bind three field in the datagrid.

    Hope it helps,

    Elton Wang


    >-----Original Message-----
    >I am setting my adapter to the below value and then

    filling the dataset and
    >binding the data grid to that after I set my dataset

    equal to the datagrid's
    >datasource. I manual bind the fields of the query to the

    datagrid. Can I
    >set my sqlDataAdapter like this. It's choking on B.QSTN

    fields but finds
    >the first three. I SQL statement below works fine in my

    query analyzer.
    >
    >SELECT A.PRSN_ID, A.LOGIN_NAME, A.ANSWER, B.QSTN, C.DESCR

    FROM
    >tblCFSPH_CM_LOGIN A INNER JOIN tblCFSPH_CM_PRSN_ROLE_LINK

    D ON A.PRSN_ID =
    >D.PRSN_ID INNER JOIN tblCFSPH_CM_ROLE C ON D.ROLE_ID =

    C.ROLE_ID LEFT JOIN
    >tblCFSPH_SECRT_QSTN B ON A.QSTN_ID = B.QSTN_ID
    >
    >Thanks!
    >
    >
    >.
    >
     
    Elton Wang, Jan 31, 2005
    #2
    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. zhaoJian
    Replies:
    0
    Views:
    1,019
    zhaoJian
    Nov 6, 2003
  2. Dan

    TimeOut on SqlDataAdapter.Fill

    Dan, Apr 3, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    7,841
  3. M
    Replies:
    7
    Views:
    17,096
    winladen
    Feb 7, 2009
  4. darrel
    Replies:
    5
    Views:
    3,653
    Lucas Tam
    May 6, 2005
  5. tom c
    Replies:
    1
    Views:
    14,867
    Jay Pondy
    Sep 16, 2006
Loading...

Share This Page