Finding records in a database

  • Thread starter Thread starter Ian
  • Start date Start date
I

Ian

Hi everyone,

I have a (probably very simple) problem which is bugging me. I have
created a form which has several controls bound to a dataset. I would
like to implement a 'search' combobox; you select the appropriate
record in the combox and the form changes the data shown. I have
created the combobox abut cannot seem to be able to change the current
data shown on the form.
I have tried using dataviews:
Dim dv As New DataView(objdstContList.Tables("Table: Controller
List"))
dv.RowFilter = "ID = " & cbx.selectedvalue
dv.Sort = "ID"
I have also tried to select a record in the dataset itself:
' objdstContList.Tables("Table: Controller
List").Select("ID = " & cbx.selectedvalue)
And a few other variations. All the code seems to be working, just not
doing what I want!

Any help would be gratefully accepted.

Ian Gaskell
 
Ian,

Funny there was somebody in the adonet newsgroup with almost the same
question as you.

This was my answer.

Probably databinding will do the trick for you and than you are ready with
the in build functionality.

http://www.vb-tips.com/default.aspx?ID=5f4a0f68-a3b6-4fc8-8aff-587f730fa118

The sample is very simple just to see the approach.

If you by instance set the same datasource to a combobox and to a
datagridview, than the binding will forever select the same row.

Be aware that you use instead of the sample because of your sorting question
forever the datatable.defaultview or another from the datatable created new
dataview.

(I did not do this in this sample to keep it simple, probably I will change
this soon, because that I am writing this forever)

I hope this gives some idea's

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top