Problem Adding Dataset
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: Problem Adding Dataset

  1. #1
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,860

    Problem Adding Datasource

    Using VS 2005 .Net 2.0

    I believe this is a problem when using Access - SQL Server works fine and does not give the following problem

    I open a new project then attempt to add a datasource (Click on Datasources Tab - Click on Add Data Source) - I select a MDB database and either One or multiple tables

    It gives me the following error

    "Reference to a non-shared member requires an object reference "
    In help it says

    You have referenced a non-shared member within your code and failed to supply an object reference. You cannot use the class name itself to qualify a member that is not shared. The instance must first be declared as an object variable and then referenced by the variable name.

    Error ID: BC30469

    To correct this error

    Declare the instance as an object variable.

    Reference the instance by the variable name.
    I dont know what this means or where to put the declarations and references

    (Last time I tried to make a Project similar to this it just worked when I use SQL Server rather than Access MDB)
    Last edited by George1111; April 22nd, 2007 at 12:36 PM.

  2. #2
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: Problem Adding Dataset

    if it does it for all MDBs, it's an internal error, reinstall visual studio
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  3. #3
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,860

    Re: Problem Adding Dataset

    I have reloaded VS 2005 and am still having problems - now also with SQL Server Databases

    What happens is that when I try to add a datasource, having selected the Table, it thinks for a while then pops up a Messagebox saying

    An error occured while creating the new datasource

    Could not get type information for "WindowsApplication1.MyDataSet"
    You then see the project full of errors. This is the code that is mentioned in the error

    (I get 102 errors listed then it stops as thats the max number or errors)

    Code:
    Error Description is "Reference to a non-shared member requires an object reference "
    
    
    When I click on the error it points to the following code -
    
    
    <System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
            Public Function IsMethod59Null() As Boolean
                Return Me.IsNull(Me.tableCONTROL_Methods.Method59Column)
            End Function
    See attached image


    Appreciate any ideas - thanks
    Attached Images Attached Images  
    Last edited by George1111; April 22nd, 2007 at 01:16 PM.

  4. #4
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,860

    Re: Problem Adding Dataset

    Here's a twist

    Clue 1

    I have a number of other SQL databases attached to the same server - which I also recently converted from Access MDB format, that are working perfectly ??

    I am wondering if it is my data types which somehow are causing problems with the database which is failing

    Looking at the databases, the only difference I can immediately see is that when creating the Failing Dtaabase I use a definition

    Number(18,6) for any Currency fields in the Access database

    The databases which work never have a Currency type data field

    Clue 2

    Some of the Tables from the Failing Database will work as Datasources without error - these tend to be small tables with either just varchar data types and also bit data types



    I am going to try to convert the database from Access to SQL Server using DTS (or whatever SQL server 2005 has to offer) - I am just installing SQL 2005 now

    All previous errors refer to SQLServerExpress

  5. #5
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,860

    HALLELUJAH !!! DO NOT USE Field name "SYSTEM"

    I have finally solved the problem of Data Source errors (after several days of battling) This included reinstalling Visual Studio 2005, SQL Server 2005 - all to no avail.

    When trying to add a data source, I was continually getting an error message (which is well documented in my posts)

    http://www.codeguru.com/forum/showthread.php?t=420883


    The problem is caused by using a Field Name "SYSTEM" in a table -

    Quote "VS just absolutely chokes on having a field called 'SYSTEM' in a table !!@!@!"


    I was lucky to find this in MSDN Forums

    http://forums.microsoft.com/MSDN/Sho...41674&SiteID=1


    BEWARE !!!

  6. #6
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,116

    Re: HALLELUJAH !!! DO NOT USE Field name "SYSTEM"

    There are tons of keywords that typically should not be used in other contexts. However for FieldNames, you should be OK, if ALL of your references to them are in "[]".
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  7. #7
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,263

    Re: HALLELUJAH !!! DO NOT USE Field name "SYSTEM"

    George, I decided to merge the threads, afterall, it's still the same topic.
    Last edited by HanneSThEGreaT; April 24th, 2007 at 01:46 AM. Reason: Fixed George's name....

  8. #8
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: Problem Adding Dataset

    It's true.. It does break quite nicely.

    The problem is caused by three things:

    1) Chiefly, that local scope references take precedence over ones that are further away. If you write the word "System" in a class the code will first look for any members of the local class before looking to namespaces. If you declared a String to have the name System:
    Dim System as String
    It effectively hides your entire system name space within its scope

    2) That VB is not case sensitive. In my C#/Oracle setup, the column is called SYSTEM and thus is distinct from the namespace System

    3) That the code designed by the dataset designer makes copius use of System.Convert, but when you have a local property called System, this is referenced instead.


    For anything else you try and confuse it with, like TABLE1Row (assuming you have a DataTable called TABLE1, therefore attempting to make a property the same name as a type) it prepends an underscore, so the property is _TABLE1Row

    Other attempts to break it in C# failed. I tried column names like base, this, global, Properties and other namespaces all succeed because the code generated by the designer doesnt ever make use of that namespace or entity, or the property was uppercased first letter (and case matters) or it realised that I had named a column as a type.

    Genius.

    The fix is quite easy: call your datatable column something else, like Systemm. It will still be mapped to the System column in the database
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  9. #9
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,860

    Re: Problem Adding Dataset

    The shame of it is that Microsoft know what potentially will cause problems and they do not provide meaningful help when problems occur.

    At least they should publish a list of "BEWARES"

    Another one I discovered some time ago was when processing data with the Account Number "CON" - this cause all manner of confusion as the Operating system though we wanted to use the Keyboard in the middle of parsing a comma delimited file !

    Thanks for the interest !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)