Web Venture 101

Creating Typed Datasets - member names cannot be the same as their enclosing type

, posted: 8-May-2006 13:24

Using typed datasets in .net 2.0 is meant to be vastly improved over .net 1.1, in terms of performance at least.  So I've decided to give them a go, which allows me to use the ObjectDataSource instead of the SQLDataSource (a more extensible architecture).

But I noticed if I create a dataset called 'Photos', and then add a tableAdapter (follow wizard**), and then rename the table to be 'Photos' also, I get a compile error "member names cannot be the same as their enclosing type".

The conflict does not refer to the name of the xsd file, but the name of the dataset it contains. 

You can either change the name of the table which may be appropriate if you have several types of 'photo' datatables in the dataset canvas (photosSimple, photosDetailed, etc), or you can change the name of the actual dataset by clicking on the dataset canvas (not one of the tables or adapters), viewing its properties, and changing its Name property to something like 'PhotosDataComponent' or some other standard.

A bit annoying, but that's how it goes at present!!

Other related posts:
Keys, Values, and NewValues when Inserting, Updating, Deleting with GridView, DetailsView, FormView and ObjectDataSource
Finding controls inside ItemTemplates inside a FormView inside a LoginView
Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the CONVERT function to run this query

Comment by Jack McMichael, on 20-Sep-2007 05:08

Thanks for this info...I was about to lose hair trying to figure out this compile error. Microsoft drives me so crazy sometimes...but as you say, que sera sera

Comment by Mike, on 13-Oct-2008 23:29

Thank you! I have been using typed datasets for several months, and all of a sudden this error popped up at compile time and run time. It was affecting about half of my datasets. Following your advice I've gone through and adjusted the DataSet Name property to have '_DS' on the end for each of the offending xsd files. This has resolved the problems for me nicely. Cheers!

Add a comment

Please note: comments that are inappropriate or promotional in nature will be deleted. E-mail addresses are not displayed, but you must enter a valid e-mail address to confirm your comments.

Are you a registered Geekzone user? Login to have the fields below automatically filled in for you and to enable links in comments. If you have (or qualify to have) a Geekzone Blog then your comment will be automatically confirmed and shown in this blog post.

Your name:

Your e-mail:

Your webpage:

ptorrsmith's profile

Peter Torr Smith
New Zealand

I've been working on a web venture idea for the last year or so, so have now resigned from my job to go at it full-time.

Here's how I go, with business and technology challenges!!