Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reference to a non-shared member requires an object reference 2

Status
Not open for further replies.

jjc3397

Programmer
Dec 21, 2003
55
US
I am getting a weird error in the VB Code as I learn to use coding. The error: Reference to a non-shared member requires an object reference. Please see Coding example below: I need someone to help me discover why this error is happening.

jjc3397

Private Sub btnCustomersFind_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnCustomersFind.Click

Dim filteredView As Data.DataView = _
New Data.DataView(NorthWindDataSet.Customers)


End Sub
End Class

Error Reference to a non-shared member requires an object reference is appearing on: NorthWindDataSet.Customers and has blue line underneath indicating the error in yellow.
 

It sounds like you're trying to use a schema named NorthwindDataSet. The dataset in Solution Explorer is just a dataset definition. You have to create an instance out of that definition to use it.

Try this:

Drag a dataset from the toolbox onto your form.
NorthwindDataSet should be an option in the Typed Dataset dropdown. Select it an click OK.
There will be a dataset instance at the bottom of the form designer. Go to its properties name it something like MyData or NorthwindData.

Use this instead of NorthWindDataSet to create your DataView.

 
I have tried doing this and get the same error message. Thanks for trying to help. I will kep trying to find an answer somehow.

The instance to NorthwindDataSet is being created, I just do not understand why it is giving the error. Also, on
New Data.DataView(NorthWindDataSet.Customers) The Intellisense is trying to put CustomerDataTable when I try placing .Customer after the NorthWindDataSet. It is something I am doing wrong, but I just can't see it!

Thanks again for your help.

jjc3397

 
I've not used a DataSet in that way so this is just really a generic reply. If Intellisense is not prompting you then generally that means that the Property or Method does not exist, it is not public and you are using it out of its scope, or the object is generically defined. I hope that helps in some way.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 

Hmm... NorthWindDataSet is the name of your instance, right?

Try replacing this:
New Data.DataView(NorthWindDataSet.Customers)

with this:
New Data.DataView(NorthWindDataSet.Tables("Customers"))

 
I was thinking that or just try NorthWindDataSet.CustomerDataTable and see what happens because .CustomerDataTable is not a method or property of a DataSet.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Thanks for the help you guys. I will try both of the examples and see what I get. Again I appreciate both of you taking your time to help me. Maybe I can help out others once I learn a little more. I am new to VB. I have tried a little Visual Basic Access with Access using Jet Sequel. I am trying real hard now to learn Transact Sequel with the SQl Server 2005 and trying real hard to learn ASP.Net with AJAX, Also, trying to learn Crystal Reports.
Most of my experience has been with COBOL and the Mainframe.

jjc3397

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top