473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to filter DataViews?

This is what I've done so far:

I have a DataBase with:

tblBook
BookID... key
Book... All the book titles of the Bible
tblChapter
ChapterID... key
Chapter... chapter numbers (1 - 150)
tblVerse
VerseID... key
Verse... verse number (1 - 100)
tblVerseText
ID... key
BookID
ChapterID
VerseID
VerseText... Each verse from the Bible, each in its own record

Created a DataAdapter for each table, (when I run the SQL statements within
the configuration wizard, they do what I want them to do):

daBook... SELECT Book,BookID FROM tblBook ORDER BY BookID

daChapter... SELECT DISTINCT tblChapter.Chapter, tblChapter.ChapterID,
tblVerseText.ChapterID AS Expr1, tblVerseText.BookID FROM tblChapter INNER
JOIN tblVerseText ON tblChapter.ChapterID = tblVerseText.ChapterID WHERE
(tblVerseText.BookID = ?) ORDER BY tblChapter.ChapterID

daVerse... SELECT DISTINCT tblVerse.Verse, tblVerse.VerseID,
tblVerseText.ChapterID, tblVerseText.VerseID AS Expr1 FROM tblVerse INNER
JOIN tblVerseText ON tblVerse.VerseID = tblVerseText.VerseID WHERE
(tblVerseText.ChapterID = ?) ORDER BY tblVerse.VerseID

daText... SELECT VerseText, ID, VerseID FROM tblVerseText WHERE (VerseID
= ?) ORDER BY ID

Created a DataView for each DataSet

dvBook
dvChapter
dvVerse
dvText

The Controls on the form are bound to the DataViews:

cmbBook > dvBook
cmbChapter > dvChapter
cmbVerse > dvVerse
lblText > dvText

I need the item that is selected in each ComboBox to filter the choices in
the subsequent ComboBoxes.

How do I write the statement in the SelectedItemChanged event to take the
value displayed and pass it's corresponding key to filter the next ComboBox?

Thanks in advance,

Gary
Nov 20 '05 #1
4 1606
Hi Gary,

You'll probably want to use the dataview findrows method, which will filter
the dataview on the argument to the findrows method, returning an array of
filtered rows. Then you'll have to empty the 'child' comboboxes, loop
through the filtered dataview and reload with the current appropriate cols
in the dataview rows array.

HTH,

Bernie Yaeger

"Bo Diddly" <hd******@hotmail.com> wrote in message
news:Of**************@tk2msftngp13.phx.gbl...
This is what I've done so far:

I have a DataBase with:

tblBook
BookID... key
Book... All the book titles of the Bible
tblChapter
ChapterID... key
Chapter... chapter numbers (1 - 150)
tblVerse
VerseID... key
Verse... verse number (1 - 100)
tblVerseText
ID... key
BookID
ChapterID
VerseID
VerseText... Each verse from the Bible, each in its own record

Created a DataAdapter for each table, (when I run the SQL statements within the configuration wizard, they do what I want them to do):

daBook... SELECT Book,BookID FROM tblBook ORDER BY BookID

daChapter... SELECT DISTINCT tblChapter.Chapter, tblChapter.ChapterID,
tblVerseText.ChapterID AS Expr1, tblVerseText.BookID FROM tblChapter INNER
JOIN tblVerseText ON tblChapter.ChapterID = tblVerseText.ChapterID WHERE (tblVerseText.BookID = ?) ORDER BY tblChapter.ChapterID

daVerse... SELECT DISTINCT tblVerse.Verse, tblVerse.VerseID,
tblVerseText.ChapterID, tblVerseText.VerseID AS Expr1 FROM tblVerse INNER
JOIN tblVerseText ON tblVerse.VerseID = tblVerseText.VerseID WHERE
(tblVerseText.ChapterID = ?) ORDER BY tblVerse.VerseID

daText... SELECT VerseText, ID, VerseID FROM tblVerseText WHERE (VerseID = ?) ORDER BY ID

Created a DataView for each DataSet

dvBook
dvChapter
dvVerse
dvText

The Controls on the form are bound to the DataViews:

cmbBook > dvBook
cmbChapter > dvChapter
cmbVerse > dvVerse
lblText > dvText

I need the item that is selected in each ComboBox to filter the choices in
the subsequent ComboBoxes.

How do I write the statement in the SelectedItemChanged event to take the
value displayed and pass it's corresponding key to filter the next ComboBox?
Thanks in advance,

Gary

Nov 20 '05 #2
Cor
Hi Bo,

Please stay with the original thread, Bernie did not know you had already
answers from OHM and me.

I think there are two methods to reach your goal. I take the one that I
think is the best. (The other is with datarelations but I think that will
consuming a lot of initial useless datatransport)

So my even simplest approach. (When you use OleDB than read OleDB where is
SQL)

You have to load your comboboxen initinal, the first one with all books, I
think and then the other ones with a dataset of the first rowvalue of each
higher combobox and in the textbox data that you get with the SQLdatareader
from the first rowvalue from the third combobox . Using SQLdatareader
methode for this gives you the less datatransport for this.

For your select see this page for the datareader (it is for stored
procedures but look for the parameters)

http://msdn.microsoft.com/library/de...ithcommand.asp

IWhen the index changes from the lowest combobox, you can read your text by
again that sqlreader I think, because that will give you the less useless
datatransport.

When the index changes from the middlest combobox, you can refresh your
dataset. For that you can use the parameter command from the datadapter,
here is a link how to do that.

http://msdn.microsoft.com/library/de...ercommands.asp

For the highest combobox it is the same as for the middle one.

And do not forget when you use the event selected index change to prevent it
to do something while initializing because that throws an event with every
change in the combobox.

I hope this helps?

Copr

This is what I've done so far:

I have a DataBase with:

tblBook
BookID... key
Book... All the book titles of the Bible
tblChapter
ChapterID... key
Chapter... chapter numbers (1 - 150)
tblVerse
VerseID... key
Verse... verse number (1 - 100)
tblVerseText
ID... key
BookID
ChapterID
VerseID
VerseText... Each verse from the Bible, each in its own record

Created a DataAdapter for each table, (when I run the SQL statements within the configuration wizard, they do what I want them to do):

daBook... SELECT Book,BookID FROM tblBook ORDER BY BookID

daChapter... SELECT DISTINCT tblChapter.Chapter, tblChapter.ChapterID,
tblVerseText.ChapterID AS Expr1, tblVerseText.BookID FROM tblChapter INNER
JOIN tblVerseText ON tblChapter.ChapterID = tblVerseText.ChapterID WHERE (tblVerseText.BookID = ?) ORDER BY tblChapter.ChapterID

daVerse... SELECT DISTINCT tblVerse.Verse, tblVerse.VerseID,
tblVerseText.ChapterID, tblVerseText.VerseID AS Expr1 FROM tblVerse INNER
JOIN tblVerseText ON tblVerse.VerseID = tblVerseText.VerseID WHERE
(tblVerseText.ChapterID = ?) ORDER BY tblVerse.VerseID

daText... SELECT VerseText, ID, VerseID FROM tblVerseText WHERE (VerseID = ?) ORDER BY ID

Created a DataView for each DataSet

dvBook
dvChapter
dvVerse
dvText

The Controls on the form are bound to the DataViews:

cmbBook > dvBook
cmbChapter > dvChapter
cmbVerse > dvVerse
lblText > dvText

I need the item that is selected in each ComboBox to filter the choices in
the subsequent ComboBoxes.

How do I write the statement in the SelectedItemChanged event to take the
value displayed and pass it's corresponding key to filter the next ComboBox?
Thanks in advance,

Gary

Nov 20 '05 #3
Bernie,

Thanks, I'll look into that as well.

Gary
Nov 20 '05 #4
Cor,

Yes, sorry about creating a new thread, I hit the wrong button!

Thanks for the links, I'll check them out.

If I wasn't so busy with other, (paying), things, I could concentrate on
this project a little more.
Trying to learn how to manipulate data and still do my regular job is eating
up a lot of my time.

Thanks for the help, I'll keep you posted,

Gary
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Robin Cull | last post by:
Imagine I have a dict looking something like this: myDict = {"key 1": , "key 2": , "key 3": , "key 4": } That is, a set of keys which have a variable length list of associated values after...
2
by: Pablo | last post by:
Hi people, Necesito crear n dataviews en tiempo de ejecucion. I need to create "n" DataViews in runtime. I tried creating an array this way: Dim LDView As Array =...
3
by: Dan V. | last post by:
How can I use real SQL on a DataTable? i.e. not array of rows using a filter... as in DataTable.Select. I read at : microsoft.public.dotnet.framework.adonet "As others have posted: There is no...
1
by: Vee Kay | last post by:
hi, this is my first post here. i'm in desparate need of resources for VC++.NET; the code in MSDN is only directed for VB/C#.. for C++ its very few and faar in between!! the web is no good...
9
by: DraguVaso | last post by:
Hi, I have two DataTables (our DataViews or whatever that will suit the best for the solution). I want to merge these two DataTables the fastest as possible, but they have to be merged one table...
4
by: Bernie Hunt | last post by:
I currently have a datagrid that I'm feeding with a DataSet, which contains three tables. I would like to use a DataView to format the DataTables but I'm not sure how to go about this. Currently...
5
by: shapper | last post by:
Hello, I have a GridView and I need to display only the records which field in datasource named "visible" is set to true. How can I do this? Thanks, Miguel
3
by: Uri Dimant | last post by:
Hello We use VS 2005. I fill a data table with simple data from database (one table) which has one column called 'flag' filtering by numbers as 1,2,3. Now that I have all data in data table I'd...
0
by: kevin.jennings | last post by:
Hi! I'm an "old-school" programmer used to dealing with data one record at a time (using old RPG code like 'chain' and 'read' statements). I'm not used to dealing with huge chunks of data at one...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.