Home All Groups Group Topic Archive Search About

Using sqlDataAdapter to fill Dataset

Author
31 Jan 2005 7:48 PM
Andy G
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!

Author
31 Jan 2005 10:12 PM
Elton Wang
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
elton_w***@hotmail.com

>-----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
Show quoteHide quote
>tblCFSPH_SECRT_QSTN B ON A.QSTN_ID = B.QSTN_ID
>
>Thanks!
>
>
>.
>