Results 1 to 6 of 6

Thread: [2005] 'Type Expected' Error

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    2

    [2005] 'Type Expected' Error

    Hi

    Wondering if anyone can help me with a very strange problem I'm experiencing. The following line of code is stopping my application from compiling with the error "Type Expected"

    The offending line of code is

    Dim rData As New Data

    I have included the correct Import statements i.e

    Imports System.Data

    Imports System.Data.SqlClient

    and have even tried re-adding System.Data as a reference and putting the dll directly into me bin directory but my project simply refuses to recognise it as a valid type. Needless to say I'm pulling my hair out trying to figure out what's going on here. Am I missing something obvious or is this some thing anyone has experienced before.

    Any help would be greatly appreciated.

    Thanks in advance.

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] 'Type Expected' Error

    System.Data is a namespace and not a type, therefor you can not declare a variable as such.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] 'Type Expected' Error

    As Atheist says. You must mean DataSet, or DataTable, or DataRow or something like that.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    2

    Re: [2005] 'Type Expected' Error

    Hi

    Thanks for the reply - You're absolutely correct on closer examination the Intellisense is indeed providing the namespace Data as the only choice (and of course I cannot declare a variable to a Namespace with the above code)

    However here's where things get more confusing: this project was developed on a server where (surprisingly it runs fine). If I type this line of code on the server then the Intellisense actually presents me with a class and not a Namespace - so there does seem to be something strange going on. We need to move this code to another box so I do need to find a solution to this. I'm presently checking all the references contained in the project and their version numbers to see in there are any differences.

    Any more thoughts on what might be causing this would be most welcome.

  5. #5
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] 'Type Expected' Error

    The project you're writing on the server must have imported some namespaces that you have not imported in your current project.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] 'Type Expected' Error

    The System namespace is imported into all VB projects by default, giving you unqualified access to its child Data namespace. I believe that all VB projects also import the System.Data namespace by default too. Certainly WinForms projects do, giving you unqualified access to the members of that namespace. You can always check which namespaces are imported into your project on the References tab of the project properties.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

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



Click Here to Expand Forum to Full Width