Using only part of the data in a datagrid
Posted on 2004-09-24
I'm filling a dataset with an entire table (because my code encounters errors if I don't). Then I want only 4 columns of that table to appear in a datagrid. Here's where I'm messed up:
I use a dataadapter to define a select * on my table, supplies_trans. Then I generate a dataset from that.
I use this code to try and start up:
Dim DRGrid As New SqlClient.SqlDataAdapter("select * from supplies_trans order by trans_date", SqlConnection1)
DBGrid1.DataSource = DataSet_Supplies1
DBGrid1.DataMember = "Supplies_Trans"
The DRGrid.Fill crashes me in these cases:
1) if the statement above it has select item, item alias, item etc (so I have to use select *)
2) if I've created a dataadapter using such a select statement other than select *
So I don't know if I can narrow it down somehow before connecting datasource/member to it. Maybe make another dataset and pull only the info I want (but I don't know the commands for this (or rather methods/etc)) or to be able to somehow say DBGrid1.only show these columns