Groups | Blog | Home
all groups > dotnet general > june 2004 >

dotnet general : ADO.net: 3 Data Set Questions (Issues)


Earl
6/26/2004 3:13:27 PM
IsDbNull and use a DataView for each combo

[quoted text, click to view]

Mr. B
6/26/2004 7:33:04 PM
I'm updating my current VB.et application. I currently reads about 6 tables
from an MS Data base. I've created a new MDB file which combines the 6 tables
into 1 table. I'm doing this because I know I'll speed up my application
loading time by more than 10 seconds (out of about 20).

I've run across three situations in which I'm stuck at:

Issue One:

If my largest Column has (say) 200 lines, other columns will have less data
lines. So say Column 1 has 50 lines of data, column 2 has 200 lines and
column 3 has 150 lines. Then column 1 and 3 will have lines containing
nothing (ie null or blank lines).

How to I test for a 'null' in a FOR statement? This is so that I can tell
when I've hit the end of my data for that column?


Issue Two:

For the above, How can I get rid of any blank lines when I bind the Datasource
to a ComboBox pull down? Column 3 will have 50 lines of blank. So if I sort
a ComboBox, the first 50 lines are blank! :(


Issue Three:

I've several ComboBox pulldowns which are bind to the same data set. But if I
change one, then the all change! How can I control them independantly?

For example, if I have 6 ComboBoxes. They are all bound to the same Data
Source, but each one is bound to a different Member of that Data Source.

So say I want to have 1 and 2 related (one changes, so does the other)... then
3 and 4 paired together similar as 1 and 2, and 5 and 6 completely independant
from all the others?

Mucho Appreciated!

Earl
6/26/2004 8:45:00 PM
If you are binding to a datasource that has the blanks within, the easiest
way is to prevent the blanks from populating when you initially pull the
data. A lot of different ways of writing your query to do that, but
basically do not return the null cells. If you are using a stored procedure,
one way is to write subqueries for each field to filter out the nulls/empty
cells.

[quoted text, click to view]

Mr. B
6/26/2004 9:33:27 PM
[quoted text, click to view]

Excellent... I got the DataView working fine! Just have to work more on the
IsDbNull part. But thanks for pointing me in the right direction!

Regards,

Mr. B
6/26/2004 10:47:06 PM
[quoted text, click to view]

Well... that solved all but Issue Two:

[quoted text, click to view]
Earl
6/27/2004 12:45:27 AM
The datasource contains the "blanks" (empty string). The easiest way to deal
with that is to prevent it at the time you read in the data from the
database. Alternatively, you have to filter that out of your dataview. Take
a look at this post:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=udVnkBvTEHA.504%40TK2MSFTNGP11.phx.gbl&rnum=2&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26scoring%3Dd%26q%3Ddataview%252Bfilter%252Bempty%26meta%3Dgroup%253Dmicrosoft.public.dotnet.framework.adonet

[quoted text, click to view]

Mr. B
6/27/2004 3:34:31 AM
[quoted text, click to view]

hmm... not 100% I'm sure what you mean... but I'll try playing with Filters
and see where I go/get. I don't recall seeing anything on this in my books...
but I'll look.

Thanks (again)!

Mr. B
6/27/2004 9:26:57 PM
[quoted text, click to view]

Easier said than done (:

I looked at your example from above... but I dont' see how I can apply it :(

I've spent the last many hours searching the web on filtering... but they all
give great fitering information... except how to get Rid of Null values :(

One that looked promising was:

If you want to filter rows with null values, you must first convert the null
values to something such as a string:

dv.RowFilter = "Isnull(Col1,'Null') = 'Null'"

But that too didn't do too much... oh well.. might as well fall back and throw
the info into a Listbox, delete the blanks and then fire the info to my
Comboboxes... A crappy way to do it, but at least I know how to do that.

This just seems way over my head (which is hurting now) (:

Thanks anyways...

Mr. B
6/28/2004 8:33:23 PM
[quoted text, click to view]

Well... I think I got it...

I found this posting:

http://www.akadia.com/services/dotnet_filter_sort.html

It said: To return only those columns with null values, use the following
expression:

"Isnull(Col1,'Null Column') = 'Null Column'"

.... So I just turned the Equal sign to Inequal (<>)... and it looks like it
solved my problem!

All the references to NULL's are no longer there in my pulldows! Just the
hard data!!!

My full code for one combo (cmbUserID) is as follows (where 'Employee' is the
column in the Table TSUpdate):

Dim usr1 As DataView = New DataView(DsTSUpdate.Tables("TSUpdate"))
usr1.RowFilter = "Isnull(Employee,'Null Column') <> 'Null Column'"
cmbUserID.DataSource = usr1
cmbUserID.DisplayMember = "Employee"


Regards,

AddThis Social Bookmark Button