Non-Shared Member

E

Earl Partridge

Using this line of code:
Dim q = From Member In BirthdaysDataSet.Member Select Member.MName
I'm told that it "Reference to a non-shared member requires an object reference".
The dataset exists in the Data Sources.
What am I missing?
Earl
 
B

Bill McCarthy

Dim ds as new BirthdaysDataSet
Dim q = From Member In ds.Member Select Member.MName


Using this line of code:
Dim q = From Member In BirthdaysDataSet.Member Select Member.MName
I'm told that it "Reference to a non-shared member requires an object
reference".
The dataset exists in the Data Sources.
What am I missing?
Earl
 
E

Earl Partridge

Thanks. That got rid of the error but I do a Q.count and the count is zero?
I have all this in a Timer event.
Earl
 
B

Bill McCarthy

Uhm, yes that is to be expected. I'm not sure you're ready for this, but
here goes ... <g>

q in this case is referred to as a projection. It's an IEnumerable, that's
all. Well actually an IEnumerable(Of String) probably. To work with q you
have touse a For Each loop as that causes the IEnumerable to step through
the items as you do. Alternatively, you can make the projection a list and
have that for each done for, eg:

Dim q = From Member In ds.Member Select Member.MName

Dim names = q.ToList


Also, I'd suggest you turn Option Strict On, as that will give you a design
time error for things that aren't there. That being said, I don't know how
you did a Q.Count on the q from the query.
 
E

Earl Partridge

The q count was done with MsgBox (q.count)...
I had this thing working correctly yesterday (in that Timers thread) but I
got things
so scattered and confused I deleted everything (kept a copy of my code),
even
uninstalled VB 2008, reinstalled it and started from scratch. The code I
saved from
yesterday produced errors, probably because I consolidated everything into a
single (different) folder.

Thanks for sticking with me. I'll try your suggestion.
Earl
 

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

Top