datgrid showing limited fields.HELP

france

Member
Joined
Feb 17, 2005
Messages
17
Location
CA
Programming Experience
1-3
i use the command:

DataAdapter.Fill(DataSet)

in order to fill my datagrid with the contents of a certain
database table.
however this didn't work when i only wanted two fields from a database table with 5 fields.

i configured my dataAdapter to select only the desired fields to show, but when i run the program, my datagrid still displays all fields.

pls. help. thank you for your kind consideration.
 
ok.. I only used the code DataAdapter.Fill(DataSet)..

did I miss any code? i Just configured my dataadapter and checked the fields I only wante dto display through the Query builder...

I also binded it to my dataset... but after all that I just used DataAdapter.Fill(DataSet).. is that wrong?
 
When you configure the dataAdapter, the Data Adapter Configuration Wizard creates the commands and command text for you. This is shown in the " Windows Form Designer generated code " region. Double check the command text for the select Command that was created.
 
ok.. I will try that...

does the code data adpater.fill(Dataset) do the job of populating the grid with my wanted fields?

do I have to configure the datamember properties of the grid?

t.y
 
fracne..

The code dataadpater.fill(Dataset) fills the dataset using the dataAdapter's SelectCommand. If you have set the dataSource property of the dataGrid (to the DataSet) and there is only one dataTable, the dataGrid will be populated with the fields since it is then binded to the dataSet. If there is more than one table, you may get the table names listed with links to the tables. It all depends on how you set things up. If you use TableStyles, you'll only get the columns listed in the TableStyle. If you set the dataSource to the dataSet and the DataMember to the table name, you should get the fields in the SELECT command, again depending on whether you use tableStyles. If you don't use tableStyles, the dataGrid should have columns matching the fields in the SelectCommand's commandText.
 
paszt

thanks.. I fixed it already.. I just generated a new dataset and it worked.. maybe I binded it to a wrong adapter at first. thanks again :)
 
Back
Top