473,786 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Chap ter, tblChapter.Chap terID,
tblVerseText.Ch apterID AS Expr1, tblVerseText.Bo okID FROM tblChapter INNER
JOIN tblVerseText ON tblChapter.Chap terID = tblVerseText.Ch apterID WHERE
(tblVerseText.B ookID = ?) ORDER BY tblChapter.Chap terID

daVerse... SELECT DISTINCT tblVerse.Verse, tblVerse.VerseI D,
tblVerseText.Ch apterID, tblVerseText.Ve rseID AS Expr1 FROM tblVerse INNER
JOIN tblVerseText ON tblVerse.VerseI D = tblVerseText.Ve rseID WHERE
(tblVerseText.C hapterID = ?) ORDER BY tblVerse.VerseI D

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 SelectedItemCha nged 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 1629
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******@hotma il.com> wrote in message
news:Of******** ******@tk2msftn gp13.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.Chap ter, tblChapter.Chap terID,
tblVerseText.Ch apterID AS Expr1, tblVerseText.Bo okID FROM tblChapter INNER
JOIN tblVerseText ON tblChapter.Chap terID = tblVerseText.Ch apterID WHERE (tblVerseText.B ookID = ?) ORDER BY tblChapter.Chap terID

daVerse... SELECT DISTINCT tblVerse.Verse, tblVerse.VerseI D,
tblVerseText.Ch apterID, tblVerseText.Ve rseID AS Expr1 FROM tblVerse INNER
JOIN tblVerseText ON tblVerse.VerseI D = tblVerseText.Ve rseID WHERE
(tblVerseText.C hapterID = ?) ORDER BY tblVerse.VerseI D

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 SelectedItemCha nged 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.Chap ter, tblChapter.Chap terID,
tblVerseText.Ch apterID AS Expr1, tblVerseText.Bo okID FROM tblChapter INNER
JOIN tblVerseText ON tblChapter.Chap terID = tblVerseText.Ch apterID WHERE (tblVerseText.B ookID = ?) ORDER BY tblChapter.Chap terID

daVerse... SELECT DISTINCT tblVerse.Verse, tblVerse.VerseI D,
tblVerseText.Ch apterID, tblVerseText.Ve rseID AS Expr1 FROM tblVerse INNER
JOIN tblVerseText ON tblVerse.VerseI D = tblVerseText.Ve rseID WHERE
(tblVerseText.C hapterID = ?) ORDER BY tblVerse.VerseI D

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 SelectedItemCha nged 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
12241
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 them. What I want to do is filter out a subset of this dict to produce another dict that satisfies a set of criteria (in this case whether it contains all four values) to end up with something
2
1491
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 = Array.CreateInstance(GetType(DataView), 10)
3
5189
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 SQL query processor for DataSets. You can use XPath with an XMLDataDocument built from the DataSet. You can also perform selections based on criteria, using the Find and Select methods, and you can create row filters using DataViews."
1
1312
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 either!! :'( now that my rant is over, here is my question: i have applied 2 dataviews on a datatable. now i want to iterate thru this dataview to see the underlying values. the views are being
9
20870
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 after the others: First all the recors of DataTable1, and afterwarths the records of DataTable2. Does anybody has any idea how to do this? The purpose it that it goes as fast as possible! DataTable2 can have up to 15.000 records, DataTable1...
4
1399
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 I have; dsVendorContacts is a DataSet with three tables and relational links dgVendors is a DataGrid With dgVendors
5
1545
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
12779
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 like to filter it by value in 'flag' column. I have three datagrid views on my form and would like to fill each grid with filtered data. I mean Sub FillDataGrid (dt as datatable) with Grid1
0
1109
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 time. Nowadays, however, it seems that the modern languages like Java and C# steer you towards working with data in a 'disconnected' fashion, i.e. loading records into datatables and datasets then using dataviews to look at them how you like. ...
0
9650
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10164
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8992
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.