By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,401 Members | 820 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,401 IT Pros & Developers. It's quick & easy.

DataSet Tables throwing a "non-shared member" error

P: 5
Using vb.net 1020
my code is fairly simple. I have a dataset with the named table in it, but I get an error on VM_Sandbox2DataSet.Tables as "Reference to a non-shared member requires an object reference."

Expand|Select|Wrap|Line Numbers
  1. Dim table As DataTable = VM_Sandbox2DataSet.Tables("OTQ_CUST_UNIT")
  2.         Dim rows() As DataRow = table.Select("Supply_Base_ID = '" & OtqSerNo_TextBox.Text & "' AND SUPPLY_LOT_ID = '" & LotID & "'")
  3.  
What am I missing?
Jan 15 '14 #1
Share this Question
Share on Google+
8 Replies


100+
P: 299
I think you have to create an instance of your dataset

Expand|Select|Wrap|Line Numbers
  1. Dim dSet As New DataSet
Hope this helps!
Jan 15 '14 #2

P: 5
BAsed on that, I assume this is what you meant
Expand|Select|Wrap|Line Numbers
  1. Dim dSet As New VM_Sandbox2DataSet
  2. Dim table As DataTable = dSet.Tables("OTQ_CUST_UNIT")
  3.  
I must be doing something wrong. While I have no errors, I also have no data showing in the table even though there are 30 records.
Jan 16 '14 #3

100+
P: 299
Yes. That's what I meant. Are you by chance using a Try..Catch? If so, either tell the exception to throw you a messagebox with the details, or eliminate the Try..Catch so you can see where your code is failing.
Jan 16 '14 #4

P: 5
I don't think it's a coding issue. I do a SELECT form the table and get zero rows.
Expand|Select|Wrap|Line Numbers
  1. Dim dSet As New VM_Sandbox2DataSet
  2. Dim table As DataTable = dSet.Tables("OTQ_CUST_UNIT")
  3. Dim rows() As DataRow = table.Select()
  4. MsgBox(rows.Count.ToString)
  5.  
What am I missing?
Jan 16 '14 #5

100+
P: 299
Without recreating your table I'm kind of shooting from the hip here, but, maybe the row count section is wrong. Try something like this:

Expand|Select|Wrap|Line Numbers
  1. MsgBox(dset.Tables(0).Rows.Count.ToString)
Edit*: Where 0 is identifying the first table in your dataset.
Jan 16 '14 #6

P: 5
Strangely all six of the tables show the correct table names, but zero records when running. There is plenty of data when I preview the data from the DataSource bar.
Jan 16 '14 #7

100+
P: 299
And you tried my code suggestion and it did not work?
Jan 16 '14 #8

100+
P: 299
I got it on my side. First, you need to make sure on your Form.vb, in design mode, that you add your Dataset and Database Table Adapter (add them sort of like a button or anything else. They are located under your Database Components).

Then it's as simple as doing this:
Expand|Select|Wrap|Line Numbers
  1. Me.DatabaseTableAdapter1.Fill(Me.DataSet1.NameOfTable
  2. MsgBox(Dataset1.Tables(0).Rows.Count)
Jan 16 '14 #9

Post your reply

Sign in to post your reply or Sign up for a free account.