Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. What's wrong...?

What's wrong...?

Scheduled Pinned Locked Moved C#
databasecomcollaborationquestion
11 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex Getman
    wrote on last edited by
    #1

    My sql query looks like select t1.code, t2.name from tab1 t1, tab2 t2 where t1.code=t2.code Then I call DataAdapter.Fill(DatasetXSD); no errors occured but DatasetXSD is empty, and when I run the same query in PL/SQL Developer everething works fine... Maybe some one can tell me anoter way to fill Dataset from multiple tables correctly? xedom developers team

    H 1 Reply Last reply
    0
    • A Alex Getman

      My sql query looks like select t1.code, t2.name from tab1 t1, tab2 t2 where t1.code=t2.code Then I call DataAdapter.Fill(DatasetXSD); no errors occured but DatasetXSD is empty, and when I run the same query in PL/SQL Developer everething works fine... Maybe some one can tell me anoter way to fill Dataset from multiple tables correctly? xedom developers team

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      I already answered your question below. You must set up table mappings. See the DataAdapter.TableMappings property documentation in the .NET Framework SDK. When you use the DataAdapter designer in VS.NET, it does this for you.

      Microsoft MVP, Visual C# My Articles

      A 1 Reply Last reply
      0
      • H Heath Stewart

        I already answered your question below. You must set up table mappings. See the DataAdapter.TableMappings property documentation in the .NET Framework SDK. When you use the DataAdapter designer in VS.NET, it does this for you.

        Microsoft MVP, Visual C# My Articles

        A Offline
        A Offline
        Alex Getman
        wrote on last edited by
        #3

        Thanx, but I tried to use mapping and got the same effect...I even create dataset fom a blank xsd file, and I create a table with 9 columns (like my query returns) and even names and types in dataset.xsd and query result are the same, but I still got an empty Dataset. Could you give me some link for mapping usage? Maybe I do somthing wrong with it.. xedom developers team

        H 1 Reply Last reply
        0
        • A Alex Getman

          Thanx, but I tried to use mapping and got the same effect...I even create dataset fom a blank xsd file, and I create a table with 9 columns (like my query returns) and even names and types in dataset.xsd and query result are the same, but I still got an empty Dataset. Could you give me some link for mapping usage? Maybe I do somthing wrong with it.. xedom developers team

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          I didn't say create a typed DataSet (which is still a good idea), I said look at the documentation for the DataAdapter.TableMappings property. Even with a typed DataSet, the DataAdapter has to know how to map tables into your DataSet (typed or read in from a schema - whatever the case may be). Open the .NET Framework SDK documentation (via the SDK start menu group or VS.NET) and type DataAdapter.TableMappings. The .NET Framework SDK includes great documentation, but you have to read it. In this case (and in many other cases), there's even an example.

          Microsoft MVP, Visual C# My Articles

          A 1 Reply Last reply
          0
          • H Heath Stewart

            I didn't say create a typed DataSet (which is still a good idea), I said look at the documentation for the DataAdapter.TableMappings property. Even with a typed DataSet, the DataAdapter has to know how to map tables into your DataSet (typed or read in from a schema - whatever the case may be). Open the .NET Framework SDK documentation (via the SDK start menu group or VS.NET) and type DataAdapter.TableMappings. The .NET Framework SDK includes great documentation, but you have to read it. In this case (and in many other cases), there's even an example.

            Microsoft MVP, Visual C# My Articles

            A Offline
            A Offline
            Alex Getman
            wrote on last edited by
            #5

            ok thank you very much...I've red all samples(can't say them are very usefull) but it still does not work... Let me tell you for what I need to work with dataset in that way: I now developing ASP.NET Application with crystal reports, to use push model I need to add DataSet maunally like xsd file. and then in my application I filling this xsd dataset. xedom developers team

            H 1 Reply Last reply
            0
            • A Alex Getman

              ok thank you very much...I've red all samples(can't say them are very usefull) but it still does not work... Let me tell you for what I need to work with dataset in that way: I now developing ASP.NET Application with crystal reports, to use push model I need to add DataSet maunally like xsd file. and then in my application I filling this xsd dataset. xedom developers team

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              Lets say the DataSet has a structure like so:

              <DataSet1>
              <t1>
              <!-- Fields -->
              </t1>
              <t1>
              <!-- Fields -->
              </t1>
              <t2>
              <!-- Fields -->
              </t2>
              <t2>
              <!-- Fields -->
              </t2>
              </DataSet1>

              Then before you execute DataAdapter.Fill, executing code similar to the following:

              dataAdapter1.TableMappings.Add("Table", "t1");
              dataAdapter1.TableMappings.Add("Table1", "t2");
              dataAdapter1.Fill(myDataSet1);

              Now, since you're using table aliases, those will be the table names used in the output so if your DataTable names use the aliases, you shouldn't need this. A DataTableMapping maps the source table name to a destination table name. Trust me - it's the reason your DataSet is empty. You must make sure that your table names in the result sets match up with the table names in the DataSet, whether that DataSet is typed, programmatically created, or read-in from an XSD.

              Microsoft MVP, Visual C# My Articles

              A 1 Reply Last reply
              0
              • H Heath Stewart

                Lets say the DataSet has a structure like so:

                <DataSet1>
                <t1>
                <!-- Fields -->
                </t1>
                <t1>
                <!-- Fields -->
                </t1>
                <t2>
                <!-- Fields -->
                </t2>
                <t2>
                <!-- Fields -->
                </t2>
                </DataSet1>

                Then before you execute DataAdapter.Fill, executing code similar to the following:

                dataAdapter1.TableMappings.Add("Table", "t1");
                dataAdapter1.TableMappings.Add("Table1", "t2");
                dataAdapter1.Fill(myDataSet1);

                Now, since you're using table aliases, those will be the table names used in the output so if your DataTable names use the aliases, you shouldn't need this. A DataTableMapping maps the source table name to a destination table name. Trust me - it's the reason your DataSet is empty. You must make sure that your table names in the result sets match up with the table names in the DataSet, whether that DataSet is typed, programmatically created, or read-in from an XSD.

                Microsoft MVP, Visual C# My Articles

                A Offline
                A Offline
                Alex Getman
                wrote on last edited by
                #7

                Ok, thnak for your information. But I think the problem is that when I run this code: OracleDataAdapter da = new OracleDataAdapter(); da = new OracleDataAdapter(sql, con); DataSet ds = new DataSet(); da.Fill(ds); Everything goes fine. But when I've just to use my xsd datset like this: OracleDataAdapter da = new OracleDataAdapter(); da = new OracleDataAdapter(sql, con); dsXSD = new DataSet(); da.Fill(dsXSD); It returns an empty dataset, only columns header are avialinle to be shown in the datagrid. xedom developers team

                H 1 Reply Last reply
                0
                • A Alex Getman

                  Ok, thnak for your information. But I think the problem is that when I run this code: OracleDataAdapter da = new OracleDataAdapter(); da = new OracleDataAdapter(sql, con); DataSet ds = new DataSet(); da.Fill(ds); Everything goes fine. But when I've just to use my xsd datset like this: OracleDataAdapter da = new OracleDataAdapter(); da = new OracleDataAdapter(sql, con); dsXSD = new DataSet(); da.Fill(dsXSD); It returns an empty dataset, only columns header are avialinle to be shown in the datagrid. xedom developers team

                  H Offline
                  H Offline
                  Heath Stewart
                  wrote on last edited by
                  #8

                  Look at the "generic" DataSet generated with the first statement. See how the tables are named. Now name the tables in your typed DataSet the same way, or use a DataTableMapping as I've said several times above. If the table names in the result set don't match up with the names of a configured DataSet, it will remain empty.

                  Microsoft MVP, Visual C# My Articles

                  A 1 Reply Last reply
                  0
                  • H Heath Stewart

                    Look at the "generic" DataSet generated with the first statement. See how the tables are named. Now name the tables in your typed DataSet the same way, or use a DataTableMapping as I've said several times above. If the table names in the result set don't match up with the names of a configured DataSet, it will remain empty.

                    Microsoft MVP, Visual C# My Articles

                    A Offline
                    A Offline
                    Alex Getman
                    wrote on last edited by
                    #9

                    Thnank you! It works now!!! I've just renamed dataset tebles...but I still don't understand how DataTableMapping works, but anyway thanx for you advises. Crystal Reports not so suitable technology as for me... xedom developers team

                    W H 2 Replies Last reply
                    0
                    • A Alex Getman

                      Thnank you! It works now!!! I've just renamed dataset tebles...but I still don't understand how DataTableMapping works, but anyway thanx for you advises. Crystal Reports not so suitable technology as for me... xedom developers team

                      W Offline
                      W Offline
                      Wackatronic
                      wrote on last edited by
                      #10

                      leTaon wrote: Crystal Reports not so suitable technology I agree. While the user's experience is great with Crystal, the developer goes through literal hell trying to get it working correctly.
                      Yes, I program in VB6, but only because I use it to fill my addiction to having a dry place to sleep and food to eat!

                      1 Reply Last reply
                      0
                      • A Alex Getman

                        Thnank you! It works now!!! I've just renamed dataset tebles...but I still don't understand how DataTableMapping works, but anyway thanx for you advises. Crystal Reports not so suitable technology as for me... xedom developers team

                        H Offline
                        H Offline
                        Heath Stewart
                        wrote on last edited by
                        #11

                        Just look at the class name: table mappings. If you look at the documentation, it maps a source table name to a destination table name, so that if the table name in the result set the DataAdapter gets is different from what you want it to be in a configured DataSet, it will map it.

                        Microsoft MVP, Visual C# My Articles

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups