FillSchema

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?QWxleCBLLg==?=

    #1

    FillSchema

    Hi all

    I noticed that if Select stmt returns dataset containing two tables,
    executing FillShema only populates schema info for first table only.

    Simple test: (.NET 2.0)

    ....
    string strSQL = "Select * from tableA select * from tableB"
    OleDbConnection cn = new OleDbConnection (strConnection) ;
    OleDbCommand cmd = new OleDbCommand(st rSQL);
    cmd.Connection = cn;
    OleDbDataAdapte r adapter = new OleDbDataAdapte r(cmd);
    DataSet ds = new DataSet();
    int ret = adapter.Fill(ds );
    adapter.FillSch ema(ds, SchemaType.Mapp ed, "Table");
    adapter.FillSch ema(ds, SchemaType.Mapp ed, "Table1");

    Everything is working fine, except that for second table, shema info is not
    set. In particular, MaxLength attribute of all string fields in second table
    is always -1. In the first table, MaxLength shows real max length of a field.

    Is there any way to fill schema for second table (and other tables if any)?

    Thank you
    Alex







  • =?Utf-8?B?QWxleCBLLg==?=

    #2
    RE: FillSchema

    (just to revive this thread:)
    Hey, C# experts, where are you?...

    "Alex K." wrote:
    Hi all
    >
    I noticed that if Select stmt returns dataset containing two tables,
    executing FillShema only populates schema info for first table only.
    >
    Simple test: (.NET 2.0)
    >
    ...
    string strSQL = "Select * from tableA select * from tableB"
    OleDbConnection cn = new OleDbConnection (strConnection) ;
    OleDbCommand cmd = new OleDbCommand(st rSQL);
    cmd.Connection = cn;
    OleDbDataAdapte r adapter = new OleDbDataAdapte r(cmd);
    DataSet ds = new DataSet();
    int ret = adapter.Fill(ds );
    adapter.FillSch ema(ds, SchemaType.Mapp ed, "Table");
    adapter.FillSch ema(ds, SchemaType.Mapp ed, "Table1");
    >
    Everything is working fine, except that for second table, shema info is not
    set. In particular, MaxLength attribute of all string fields in second table
    is always -1. In the first table, MaxLength shows real max length of a field.
    >
    Is there any way to fill schema for second table (and other tables if any)?
    >
    Thank you
    Alex
    >
    >
    >
    >
    >
    >
    >

    Comment

    • Liz

      #3
      Re: FillSchema

      string strSQL = "Select * from tableA select * from tableB"
      where's the semi-colon?

      string strSQL = "SELECT * FROM tableA; SELECT * FROM tableB"

      I would have thought you'd get a SQL Exception ....


      "Alex K." <AlexK@discussi ons.microsoft.c omwrote in message
      news:C9501AD3-A172-4744-8FCA-E088AD9A65EC@mi crosoft.com...
      (just to revive this thread:)
      Hey, C# experts, where are you?...
      >
      "Alex K." wrote:
      >
      >Hi all
      >>
      >I noticed that if Select stmt returns dataset containing two tables,
      >executing FillShema only populates schema info for first table only.
      >>
      >Simple test: (.NET 2.0)
      >>
      >...
      >string strSQL = "Select * from tableA select * from tableB"
      >OleDbConnectio n cn = new OleDbConnection (strConnection) ;
      >OleDbCommand cmd = new OleDbCommand(st rSQL);
      >cmd.Connecti on = cn;
      >OleDbDataAdapt er adapter = new OleDbDataAdapte r(cmd);
      >DataSet ds = new DataSet();
      >int ret = adapter.Fill(ds );
      >adapter.FillSc hema(ds, SchemaType.Mapp ed, "Table");
      >adapter.FillSc hema(ds, SchemaType.Mapp ed, "Table1");
      >>
      >Everything is working fine, except that for second table, shema info is
      >not
      >set. In particular, MaxLength attribute of all string fields in second
      >table
      >is always -1. In the first table, MaxLength shows real max length of a
      >field.
      >>
      >Is there any way to fill schema for second table (and other tables if
      >any)?
      >>
      >Thank you
      >Alex
      >>
      >>
      >>
      >>
      >>
      >>
      >>

      Comment

      • Peter Duniho

        #4
        Re: FillSchema

        On 2007-11-30 09:18:01 -0800, Alex K. <AlexK@discussi ons.microsoft.c omsaid:
        (just to revive this thread:)
        Hey, C# experts, where are you?...
        For what it's worth, I didn't see anything in your question that had
        anything specific to do with C#.

        It appears to be primarily a database question. Granted, there are
        several C# experts following this newsgroup who _also_ are database
        experts, and they do in fact sometimes answer database questions here.

        But if you've got a database question and you really really need an
        answer, you're probably better off posting the question to a database
        newsgroup (even one that still is specific to .NET, if appropriate).

        Pete

        Comment

        • =?Utf-8?B?QWxleCBLLg==?=

          #5
          Re: FillSchema

          Peter,

          the question is about how C# function FillSchema works, not about how
          database works. On database side, I have no problems at all - of course, both
          db tables have all their properties in place.

          When you create a dataset using Select stmt, and then look into datatables
          that are contained in that dataset, you will see that MaxLength property is
          not populated unless you execute FillSchema on that dataset.

          My question is: why FillSchema call only populates schema properties (e.g.
          MaxLength) only for the first datatable in dataset?

          Thank you for your response.


          "Peter Duniho" wrote:
          On 2007-11-30 09:18:01 -0800, Alex K. <AlexK@discussi ons.microsoft.c omsaid:
          >
          (just to revive this thread:)
          Hey, C# experts, where are you?...
          >
          For what it's worth, I didn't see anything in your question that had
          anything specific to do with C#.
          >
          It appears to be primarily a database question. Granted, there are
          several C# experts following this newsgroup who _also_ are database
          experts, and they do in fact sometimes answer database questions here.
          >
          But if you've got a database question and you really really need an
          answer, you're probably better off posting the question to a database
          newsgroup (even one that still is specific to .NET, if appropriate).
          >
          Pete
          >
          >

          Comment

          • Liz

            #6
            Re: FillSchema


            Alex, here's your answer, direct from the docs:

            Note
            If the FillSchema method of the OleDbDataAdapte r object is called for a
            command that returns multiple result sets, only the schema information from
            the first result set is returned. When returning schema information for
            multiple result sets using the OleDbDataAdapte r, it is recommended that you
            specify a MissingSchemaAc tion of AddWithKey and obtain the schema
            information when calling the Fill method.

            Look for the topic:

            "Adding Existing Constraints to a DataSet"

            Liz



            "Alex K." <AlexK@discussi ons.microsoft.c omwrote in message
            news:0BACDDCD-CA37-49CE-BB86-C1389FD60267@mi crosoft.com...
            Peter,
            >
            the question is about how C# function FillSchema works, not about how
            database works. On database side, I have no problems at all - of course,
            both
            db tables have all their properties in place.
            >
            When you create a dataset using Select stmt, and then look into datatables
            that are contained in that dataset, you will see that MaxLength property
            is
            not populated unless you execute FillSchema on that dataset.
            >
            My question is: why FillSchema call only populates schema properties (e.g.
            MaxLength) only for the first datatable in dataset?
            >
            Thank you for your response.
            >
            >
            "Peter Duniho" wrote:
            >
            >On 2007-11-30 09:18:01 -0800, Alex K. <AlexK@discussi ons.microsoft.c om>
            >said:
            >>
            (just to revive this thread:)
            Hey, C# experts, where are you?...
            >>
            >For what it's worth, I didn't see anything in your question that had
            >anything specific to do with C#.
            >>
            >It appears to be primarily a database question. Granted, there are
            >several C# experts following this newsgroup who _also_ are database
            >experts, and they do in fact sometimes answer database questions here.
            >>
            >But if you've got a database question and you really really need an
            >answer, you're probably better off posting the question to a database
            >newsgroup (even one that still is specific to .NET, if appropriate).
            >>
            >Pete
            >>
            >>

            Comment

            • =?Utf-8?B?QWxleCBLLg==?=

              #7
              Re: FillSchema

              Thank you, Liz

              I have read this topic in the HELP. It didn't help much: I tried. When I do
              this, it is trying to add UniqueConstrain t which causes another problems with
              my query (real query, not the example I posted). Error handling routine grows
              crazy.

              I still hope to find simple and elegant solution to populate schema info in
              multi-table dataset ... :-|

              Thanks again.
              Alex
              "Liz" wrote:
              >
              Alex, here's your answer, direct from the docs:
              >
              Note
              If the FillSchema method of the OleDbDataAdapte r object is called for a
              command that returns multiple result sets, only the schema information from
              the first result set is returned. When returning schema information for
              multiple result sets using the OleDbDataAdapte r, it is recommended that you
              specify a MissingSchemaAc tion of AddWithKey and obtain the schema
              information when calling the Fill method.
              >
              Look for the topic:
              >
              "Adding Existing Constraints to a DataSet"
              >
              Liz
              >
              >
              >
              "Alex K." <AlexK@discussi ons.microsoft.c omwrote in message
              news:0BACDDCD-CA37-49CE-BB86-C1389FD60267@mi crosoft.com...
              >
              Peter,

              the question is about how C# function FillSchema works, not about how
              database works. On database side, I have no problems at all - of course,
              both
              db tables have all their properties in place.

              When you create a dataset using Select stmt, and then look into datatables
              that are contained in that dataset, you will see that MaxLength property
              is
              not populated unless you execute FillSchema on that dataset.

              My question is: why FillSchema call only populates schema properties (e.g.
              MaxLength) only for the first datatable in dataset?

              Thank you for your response.


              "Peter Duniho" wrote:
              On 2007-11-30 09:18:01 -0800, Alex K. <AlexK@discussi ons.microsoft.c om>
              said:
              >
              (just to revive this thread:)
              Hey, C# experts, where are you?...
              >
              For what it's worth, I didn't see anything in your question that had
              anything specific to do with C#.
              >
              It appears to be primarily a database question. Granted, there are
              several C# experts following this newsgroup who _also_ are database
              experts, and they do in fact sometimes answer database questions here.
              >
              But if you've got a database question and you really really need an
              answer, you're probably better off posting the question to a database
              newsgroup (even one that still is specific to .NET, if appropriate).
              >
              Pete
              >
              >
              >
              >
              >

              Comment

              • Liz

                #8
                Re: FillSchema


                have you queried microsoft.publi c.dotnet.framew ork.adonet ? I don't know
                anything about the NG but it has the right name .... :)


                "Alex K." <AlexK@discussi ons.microsoft.c omwrote in message
                news:ED99B050-9738-4A79-A2AC-ACC108C87299@mi crosoft.com...
                Thank you, Liz
                >
                I have read this topic in the HELP. It didn't help much: I tried. When I
                do
                this, it is trying to add UniqueConstrain t which causes another problems
                with
                my query (real query, not the example I posted). Error handling routine
                grows
                crazy.
                >
                I still hope to find simple and elegant solution to populate schema info
                in
                multi-table dataset ... :-|
                >
                Thanks again.
                Alex
                "Liz" wrote:
                >
                >>
                >Alex, here's your answer, direct from the docs:
                >>
                >Note
                >If the FillSchema method of the OleDbDataAdapte r object is called for a
                >command that returns multiple result sets, only the schema information
                >from
                >the first result set is returned. When returning schema information for
                >multiple result sets using the OleDbDataAdapte r, it is recommended that
                >you
                >specify a MissingSchemaAc tion of AddWithKey and obtain the schema
                >information when calling the Fill method.
                >>
                >Look for the topic:
                >>
                >"Adding Existing Constraints to a DataSet"
                >>
                >Liz
                >>
                >>
                >>
                >"Alex K." <AlexK@discussi ons.microsoft.c omwrote in message
                >news:0BACDDC D-CA37-49CE-BB86-C1389FD60267@mi crosoft.com...
                >>
                Peter,
                >
                the question is about how C# function FillSchema works, not about how
                database works. On database side, I have no problems at all - of
                course,
                both
                db tables have all their properties in place.
                >
                When you create a dataset using Select stmt, and then look into
                datatables
                that are contained in that dataset, you will see that MaxLength
                property
                is
                not populated unless you execute FillSchema on that dataset.
                >
                My question is: why FillSchema call only populates schema properties
                (e.g.
                MaxLength) only for the first datatable in dataset?
                >
                Thank you for your response.
                >
                >
                "Peter Duniho" wrote:
                >
                >On 2007-11-30 09:18:01 -0800, Alex K.
                ><AlexK@discuss ions.microsoft. com>
                >said:
                >>
                (just to revive this thread:)
                Hey, C# experts, where are you?...
                >>
                >For what it's worth, I didn't see anything in your question that had
                >anything specific to do with C#.
                >>
                >It appears to be primarily a database question. Granted, there are
                >several C# experts following this newsgroup who _also_ are database
                >experts, and they do in fact sometimes answer database questions here.
                >>
                >But if you've got a database question and you really really need an
                >answer, you're probably better off posting the question to a database
                >newsgroup (even one that still is specific to .NET, if appropriate).
                >>
                >Pete
                >>
                >>
                >>
                >>
                >>

                Comment

                • Peter Duniho

                  #9
                  Re: FillSchema

                  On Sat, 01 Dec 2007 06:43:00 -0800, Alex K.
                  <AlexK@discussi ons.microsoft.c omwrote:
                  Thank you, Peter
                  >
                  When we talk about databases, we mean different things. What I call
                  database, is a SQL Server database, Oracle database, MS Jet database etc.
                  What you call database is just .NET database layer, database-oriented
                  part of .NET function set.
                  No, it's not "just" that. But yes, I do include the .NET database layer.
                  Yes, you are right when you are saying that FillSchema question is more
                  about .NET database layer. But as I told you, it has nothing to do with
                  databases themselves because not SQL Server, nor Oracle, nor Jet have
                  function called "FillSChema ".
                  So are you saying that any "C# expert" should be able to answer your
                  question? If not, I don't see why you are debating this at all. If so,
                  why does being an expert in C# imply knowledge of database-related topics?
                  [...]
                  When readers are posting questions about sockets, graphics or XML,
                  (examples from current page), they are not asking about C# using
                  your meaning of the word.
                  I readily acknowledge the large amount of traffic in this newsgroup that
                  is theoretically off-topic. My point is not to argue that you shouldn't
                  have asked your question here, and had you read what I'd written you'd
                  understand that.

                  My point _is_ that your impatience with the people in this newsgroup is
                  ill-placed. While you're free to ask the question here, you have no
                  reason to expect it would be answered. That's true for any question, of
                  course, but even more so for something as esoteric as the issue you're
                  running into.
                  [...] With your
                  permission or not, I will continue to post here all questions that I may
                  have about using C# in real world tasks
                  Again, you clearly have not bothered to read what I wrote. This isn't
                  about what you _may_ post here. It's about unreasonable expectations of
                  what sort of response you might get. Posting your original question
                  wasn't a problem at all. Acting like a "C# expert" ought to know the
                  answer to your question is a problem.

                  Furthermore, it's only a problem inasmuch as it sets you up for
                  disappointment. I'm not trying to take you task for doing something
                  wrong, as it seems like you think I am doing. Where does "with your
                  permission or not" come from? I'm not telling you what you may or may not
                  do. I'm just trying to be helpful.

                  If you don't appreciate the help, fine. But I don't see why you feel the
                  need to argue about what a "database question" is, and there's certainly
                  no need for the offense you appear to have taken regarding my motives.

                  Pete

                  Comment

                  Working...