Home All Groups Group Topic Archive Search About

Question on Dataset navigation vb.net

Author
18 Jan 2006 1:26 AM
Newbie
Could someone answer a vb.net database question?   what is a good
way to code a form so that a user could navigate through a dataset ie:
MoveFirst, MoveNext, MovePrevious, MoveLast, Update and Delete records
and have an option to find a record.  I have been able to figure out
how to navigate both using bound and unbound controls.  But I can't
figure out how to do the Navigation and find a record at the same time.
Do most people use one connection, dataAdapter, Dataset for browsing a
table and then if a user wishes to Search for a unique record do you
close the first dataset and open another using a sql string like
"SELECT * FROM datatable WHERE PK = ?"  What has me confused with that
idea is if a user found a record using the some type of (search)
dataset routine, how do I set up the program so that the user can just
click MoveNext again and movenext or moveprev from that record that
he/she just was viewing?


Thanks


Newbie

Author
18 Jan 2006 9:17 AM
Cyril Gupta
You have asked a question that has a really big answer if someone tries to
explain it.

But in short...

VB retrieves all of the records you ask for in one go, so there is no
question of movewhatever.

Use the Row property of the DataTable in your DataSet and set the Index
number of your ROw to access individual rowdata. this a collection, so it's
gonna be easy.

Here's a sample codett that retrieves all the rows from the datatable

Dim dRow as datarow
for each drow in mydatatable.rows
  console.writeline drow.item("myfield")
next

Cyril
Author
18 Jan 2006 9:20 AM
Cor Ligthert [MVP]
Newbie,

The currencymanager is for what you ask.

Have a look at this simple sample.

http://www.vb-tips.com/default.aspx?ID=c6c7d9a8-7511-41a1-a488-2e91e5295e7c

I hope this helps,

Cor
Author
18 Jan 2006 9:58 AM
Cyril Gupta
Cor,

It's amazing how much .Net has. I didn't know that CurrencyManager existed.
It sounds like a pretty interesting thing.

Thanks
Cyril
Author
18 Jan 2006 3:12 PM
Newbie
Thanks for the info guy's,  I guess I should not have made the question
so broad, what I should have asked is would it be better to use unbound
controls vs bound controls.  I can see using bound controls will be
faster in development but you lose control with what you can do.  In
the above question I am looking at creating a form with text box's that
display fields from a dataset.  I wanted to give a user the ability to
navigate through the dataset using MoveFirst, MoveNext buttons but also
offer a search option.    I will look into the CurrencyManager for more
ideas

Thanks

Newbie