Generated Code Won't Compile

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Curt Emich

    #1

    Generated Code Won't Compile

    I'm trying to create a dataset. I start by creating a connection. Then I
    create and configure a data adapter. Finally, I select "generate dataset"
    after right-clicking on the data adapter. It creates a dataset and puts it
    under the form, just like the connection and the adapter.

    When I try to compile the code GENERTED BY THE IDE, it bombs. Here's the
    code:

    protected System.Data.Ole Db.OleDbCommand oleDbSelectComm and1;

    protected System.Data.Ole Db.OleDbCommand oleDbInsertComm and1;

    protected System.Data.Ole Db.OleDbCommand oleDbUpdateComm and1;

    protected System.Data.Ole Db.OleDbCommand oleDbDeleteComm and1;

    protected System.Data.Ole Db.OleDbDataAda pter oleDbDataAdapte r1;

    protected TrainOfThought. DataSet1 dataSet11;



    It bombs on the last line. It says that the type or namespace "DataSet1"
    does not exist. I never said it did. Does anyone know why .NET would bomb
    on its own code? What can I do to fix this?




  • Frans Bouma [C# MVP]

    #2
    Re: Generated Code Won't Compile

    Curt Emich wrote:
    [color=blue]
    > I'm trying to create a dataset. I start by creating a connection. Then I
    > create and configure a data adapter. Finally, I select "generate dataset"
    > after right-clicking on the data adapter. It creates a dataset and puts it
    > under the form, just like the connection and the adapter.
    >
    > When I try to compile the code GENERTED BY THE IDE, it bombs. Here's the
    > code:
    >
    > protected System.Data.Ole Db.OleDbCommand oleDbSelectComm and1;
    >
    > protected System.Data.Ole Db.OleDbCommand oleDbInsertComm and1;
    >
    > protected System.Data.Ole Db.OleDbCommand oleDbUpdateComm and1;
    >
    > protected System.Data.Ole Db.OleDbCommand oleDbDeleteComm and1;
    >
    > protected System.Data.Ole Db.OleDbDataAda pter oleDbDataAdapte r1;
    >
    > protected TrainOfThought. DataSet1 dataSet11;
    >
    >
    >
    > It bombs on the last line. It says that the type or namespace "DataSet1"
    > does not exist. I never said it did. Does anyone know why .NET would bomb
    > on its own code? What can I do to fix this?[/color]

    Did you add the generated dataset to your project?

    Frans.


    --
    Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
    My .NET Blog: http://weblogs.asp.net/fbouma
    Microsoft C# MVP

    Comment

    • Frans Bouma [C# MVP]

      #3
      Re: Generated Code Won't Compile

      Curt Emich wrote:
      [color=blue]
      > I'm trying to create a dataset. I start by creating a connection. Then I
      > create and configure a data adapter. Finally, I select "generate dataset"
      > after right-clicking on the data adapter. It creates a dataset and puts it
      > under the form, just like the connection and the adapter.
      >
      > When I try to compile the code GENERTED BY THE IDE, it bombs. Here's the
      > code:
      >
      > protected System.Data.Ole Db.OleDbCommand oleDbSelectComm and1;
      >
      > protected System.Data.Ole Db.OleDbCommand oleDbInsertComm and1;
      >
      > protected System.Data.Ole Db.OleDbCommand oleDbUpdateComm and1;
      >
      > protected System.Data.Ole Db.OleDbCommand oleDbDeleteComm and1;
      >
      > protected System.Data.Ole Db.OleDbDataAda pter oleDbDataAdapte r1;
      >
      > protected TrainOfThought. DataSet1 dataSet11;
      >
      >
      >
      > It bombs on the last line. It says that the type or namespace "DataSet1"
      > does not exist. I never said it did. Does anyone know why .NET would bomb
      > on its own code? What can I do to fix this?[/color]

      Did you add the generated dataset to your project?

      Frans.


      --
      Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
      My .NET Blog: http://weblogs.asp.net/fbouma
      Microsoft C# MVP

      Comment

      • Cor Ligthert

        #4
        Re: Generated Code Won't Compile

        Hi Curt,

        I am not sure what it does in C# however sometimes in VB the code stays in
        the designer when you make some corrections afterwards .

        Did you try it with a new project again?.

        Cor


        Comment

        • Cor Ligthert

          #5
          Re: Generated Code Won't Compile

          Hi Curt,

          I am not sure what it does in C# however sometimes in VB the code stays in
          the designer when you make some corrections afterwards .

          Did you try it with a new project again?.

          Cor


          Comment

          • William Ryan eMVP

            #6
            Re: Generated Code Won't Compile

            Hi Curt:

            A few questions:

            First, if you look in the solution explorer, do you see a xsd that matches
            the one you just made? I'm just wondering b/c I've repeated the steps you
            mentioned and it worked by default. However, this is the actual reference
            line it generated:
            <<protected TrainOfThought. DataSet1 dataSet11;>>
            Basically the same as yours other than the form name and the access
            modifier. That's not surprising. However, my project has the DataSet1.xsd.
            However, if I right click on DataSet1.xsd in the solution explorer and
            choose Exclude from Project.. I still have my declaration as above but I
            know get this exception when I try to compile:
            <<C:\WindowsApp lication5\Form1 .cs(33): The type or namespace name 'DataSet1'
            does not exist in the class or namespace 'WindowsApplica tion5' (are you
            missing an assembly reference?)>> Which is the same thing you are having.

            Just to see if this may have happened accidentally , select the Project menu
            item and then check Show All Files. See if it doesn't appear afterward (it
            so, it will probably have a blank white icon instead of your typical form
            icons or class icons.

            2) I'm not sure what options you chose when you generated the dataset. You
            have a choice where to gen the new dataset, in a new one or an existing one.
            You'll should have a choice of each table that you've created a dataadapter
            for that has a Select Command. Finally, there's an option for adding the
            dataset to the designer. I'm just wondering which options you chose (New
            vs. Existing, and did you unchoose the Add DataSet to designer option?

            I think the most likely culprit is that the xsd somehow was excluded or
            there was an error when generating it. As such, it's not visible to your
            class so it's raising the error. If you choose Show all files and you see
            it, then just include it in the project and it should be fine. If not, then
            it must have either never been generated correctly or somehow got deleted.
            IF that's the case, delete the line causing the exception and just start ove
            r again with generating the dataset. It should be fine.

            Finally, what do you mean by the comment "It says that the type or namespace
            "DataSet1"[color=blue]
            > does not exist. I never said it did. " when you say "I never said it[/color]
            did"? That makes me think it was excluded or specifically you didn't chose
            the add to designer option, but that's purely conjecture and that's why I
            mention it. Since I think the most likely problem is the exlusion of the
            file, that's probably what caused it if my guess is correct (but like I
            said, it's just a guess that's why I ask).
            Let me know and hopefully we can get to the bottom of it.

            Cheers

            Bill

            "Curt Emich" <cemich@comcast .net> wrote in message
            news:ZK-dnYxaxOOIRhTdRV n-uQ@comcast.com. ..[color=blue]
            > I'm trying to create a dataset. I start by creating a connection. Then I
            > create and configure a data adapter. Finally, I select "generate dataset"
            > after right-clicking on the data adapter. It creates a dataset and puts[/color]
            it[color=blue]
            > under the form, just like the connection and the adapter.
            >
            > When I try to compile the code GENERTED BY THE IDE, it bombs. Here's the
            > code:
            >
            > protected System.Data.Ole Db.OleDbCommand oleDbSelectComm and1;
            >
            > protected System.Data.Ole Db.OleDbCommand oleDbInsertComm and1;
            >
            > protected System.Data.Ole Db.OleDbCommand oleDbUpdateComm and1;
            >
            > protected System.Data.Ole Db.OleDbCommand oleDbDeleteComm and1;
            >
            > protected System.Data.Ole Db.OleDbDataAda pter oleDbDataAdapte r1;
            >
            > protected TrainOfThought. DataSet1 dataSet11;
            >
            >
            >
            > It bombs on the last line. It says that the type or namespace "DataSet1"
            > does not exist. I never said it did. Does anyone know why .NET would[/color]
            bomb[color=blue]
            > on its own code? What can I do to fix this?
            >
            >
            >
            >[/color]


            Comment

            • William Ryan eMVP

              #7
              Re: Generated Code Won't Compile

              Hi Curt:

              A few questions:

              First, if you look in the solution explorer, do you see a xsd that matches
              the one you just made? I'm just wondering b/c I've repeated the steps you
              mentioned and it worked by default. However, this is the actual reference
              line it generated:
              <<protected TrainOfThought. DataSet1 dataSet11;>>
              Basically the same as yours other than the form name and the access
              modifier. That's not surprising. However, my project has the DataSet1.xsd.
              However, if I right click on DataSet1.xsd in the solution explorer and
              choose Exclude from Project.. I still have my declaration as above but I
              know get this exception when I try to compile:
              <<C:\WindowsApp lication5\Form1 .cs(33): The type or namespace name 'DataSet1'
              does not exist in the class or namespace 'WindowsApplica tion5' (are you
              missing an assembly reference?)>> Which is the same thing you are having.

              Just to see if this may have happened accidentally , select the Project menu
              item and then check Show All Files. See if it doesn't appear afterward (it
              so, it will probably have a blank white icon instead of your typical form
              icons or class icons.

              2) I'm not sure what options you chose when you generated the dataset. You
              have a choice where to gen the new dataset, in a new one or an existing one.
              You'll should have a choice of each table that you've created a dataadapter
              for that has a Select Command. Finally, there's an option for adding the
              dataset to the designer. I'm just wondering which options you chose (New
              vs. Existing, and did you unchoose the Add DataSet to designer option?

              I think the most likely culprit is that the xsd somehow was excluded or
              there was an error when generating it. As such, it's not visible to your
              class so it's raising the error. If you choose Show all files and you see
              it, then just include it in the project and it should be fine. If not, then
              it must have either never been generated correctly or somehow got deleted.
              IF that's the case, delete the line causing the exception and just start ove
              r again with generating the dataset. It should be fine.

              Finally, what do you mean by the comment "It says that the type or namespace
              "DataSet1"[color=blue]
              > does not exist. I never said it did. " when you say "I never said it[/color]
              did"? That makes me think it was excluded or specifically you didn't chose
              the add to designer option, but that's purely conjecture and that's why I
              mention it. Since I think the most likely problem is the exlusion of the
              file, that's probably what caused it if my guess is correct (but like I
              said, it's just a guess that's why I ask).
              Let me know and hopefully we can get to the bottom of it.

              Cheers

              Bill

              "Curt Emich" <cemich@comcast .net> wrote in message
              news:ZK-dnYxaxOOIRhTdRV n-uQ@comcast.com. ..[color=blue]
              > I'm trying to create a dataset. I start by creating a connection. Then I
              > create and configure a data adapter. Finally, I select "generate dataset"
              > after right-clicking on the data adapter. It creates a dataset and puts[/color]
              it[color=blue]
              > under the form, just like the connection and the adapter.
              >
              > When I try to compile the code GENERTED BY THE IDE, it bombs. Here's the
              > code:
              >
              > protected System.Data.Ole Db.OleDbCommand oleDbSelectComm and1;
              >
              > protected System.Data.Ole Db.OleDbCommand oleDbInsertComm and1;
              >
              > protected System.Data.Ole Db.OleDbCommand oleDbUpdateComm and1;
              >
              > protected System.Data.Ole Db.OleDbCommand oleDbDeleteComm and1;
              >
              > protected System.Data.Ole Db.OleDbDataAda pter oleDbDataAdapte r1;
              >
              > protected TrainOfThought. DataSet1 dataSet11;
              >
              >
              >
              > It bombs on the last line. It says that the type or namespace "DataSet1"
              > does not exist. I never said it did. Does anyone know why .NET would[/color]
              bomb[color=blue]
              > on its own code? What can I do to fix this?
              >
              >
              >
              >[/color]


              Comment

              • Curt Emich

                #8
                Re: Generated Code Won't Compile

                Those .xsd files were there, but they still didn't work. I manually
                typed in a dataset, and it works fine. I just thought the IDE would be
                more reliable. Thanks to everyone for your feedback.

                *** Sent via Developersdex http://www.developersdex.com ***
                Don't just participate in USENET...get rewarded for it!

                Comment

                • Curt Emich

                  #9
                  Re: Generated Code Won't Compile

                  Those .xsd files were there, but they still didn't work. I manually
                  typed in a dataset, and it works fine. I just thought the IDE would be
                  more reliable. Thanks to everyone for your feedback.

                  *** Sent via Developersdex http://www.developersdex.com ***
                  Don't just participate in USENET...get rewarded for it!

                  Comment

                  • William Ryan  eMVP

                    #10
                    Re: Generated Code Won't Compile

                    It's pretty reliable but it's not infallible. There's a lot that can go
                    wrong. and considering the possibilities, it's impressive it works as well
                    as it does. I'm glad you got it fixed though.

                    Cheers,

                    Bill
                    "Curt Emich" <cemich@comcast .net> wrote in message
                    news:e9ExvxjKEH A.2716@tk2msftn gp13.phx.gbl...[color=blue]
                    > Those .xsd files were there, but they still didn't work. I manually
                    > typed in a dataset, and it works fine. I just thought the IDE would be
                    > more reliable. Thanks to everyone for your feedback.
                    >
                    > *** Sent via Developersdex http://www.developersdex.com ***
                    > Don't just participate in USENET...get rewarded for it![/color]


                    Comment

                    • William Ryan  eMVP

                      #11
                      Re: Generated Code Won't Compile

                      It's pretty reliable but it's not infallible. There's a lot that can go
                      wrong. and considering the possibilities, it's impressive it works as well
                      as it does. I'm glad you got it fixed though.

                      Cheers,

                      Bill
                      "Curt Emich" <cemich@comcast .net> wrote in message
                      news:e9ExvxjKEH A.2716@tk2msftn gp13.phx.gbl...[color=blue]
                      > Those .xsd files were there, but they still didn't work. I manually
                      > typed in a dataset, and it works fine. I just thought the IDE would be
                      > more reliable. Thanks to everyone for your feedback.
                      >
                      > *** Sent via Developersdex http://www.developersdex.com ***
                      > Don't just participate in USENET...get rewarded for it![/color]


                      Comment

                      Working...