Problem With Typed DataSet Schema

Discussion in 'ASP .Net Web Services' started by OhioGolfer, Nov 8, 2005.

  1. OhioGolfer

    OhioGolfer Guest

    My app consists of a windows form client, a business logic layer, and a
    web application that hosts a strongly typed dataset and a variety of
    web services. The web services retrieve the data from the SQL Server
    database, do whatever logical processing is required, and return the
    results to the business logic layer, which holds the data in an
    instance of the typed dataset.

    In my typed dataset, I have added annotations to the xsd file to
    provide nullValue values, and avoid the StrongTypingException issue
    when nulls are present in the data store. However, when the app runs,
    the StrongTypingException still is thrown. When I go into the
    Reference.vb file, and check the xsd that the reference is hitting, the
    annotations are not there. It is obviously generating its own schema,
    while I want it to use the schema in the web application.

    Any ideas on how to get around this? It is driving me crazy . . .

    Jeff
     
    OhioGolfer, Nov 8, 2005
    #1
    1. Advertising

  2. Hi Jeff,

    I would like to know how you set the nullValue for a certain column. Did
    you modified the attribute in the xsd? Also are the business logic layer
    and the webservice layer referencing to the same typed DataSet class?

    Please take a look at the following KB article. It will be a good guide for
    your to handle DBNull values in typed DataSet.

    http://support.microsoft.com/default.aspx?scid=kb;en-us;318048

    Kevin Yu
    =======
    "This posting is provided "AS IS" with no warranties, and confers no
    rights."
     
    Kevin Yu [MSFT], Nov 9, 2005
    #2
    1. Advertising

  3. OhioGolfer

    OhioGolfer Guest

    Kevin -- I modified the .xsd file by adding the
    xmlns:codegen="urn:schemas-microsoft-com:xml-msprop" reference, and
    adding codegen:nullValue="_empty" or "0" or "1980-01-01", depending
    upon the field type involved. This works fine on the server side --
    the .vb file for the typed dataset properly incorporates the
    annotations, and no StrongTypingException is thrown.

    The problem arises on the client side. The web reference to the web
    service regenerates the schema as part of the reference, and drops the
    annotations. Thus, the Reference.vb file throws the
    StrongTypingException. I have tried modifying the .wsdl file to point
    to the "original" xsd schema, but that doesn't work. I could modify
    the Reference.vb file, but this is an unstable solution, as those
    changes will be lost anytime the reference is updated.

    There have been a few allusions to this as a known bug in the web
    service treatment of typed datasets in other forums, but I have yet to
    see a proposed solution. Hope you can shed some light on this.

    Jeff
     
    OhioGolfer, Nov 9, 2005
    #3
  4. Hi Jeff,

    With my further research, I found that it is a known issue in ADO .net.
    When XmlSerializing the typed dataset, the extended properties will not be
    persisted. So the nullValue attribute cannot be passed through a web
    service.

    Kevin Yu
    =======
    "This posting is provided "AS IS" with no warranties, and confers no
    rights."
     
    Kevin Yu [MSFT], Nov 10, 2005
    #4
  5. OhioGolfer

    OhioGolfer Guest

    Kevin -- That's it? No workaround, no indication as to whether this is
    fixed in 2.0? With the push of Smart Client architecture, I find it
    hard to believe that MS is simply stating this can't be done. Are you
    really implying that we either have to abandon typed datasets when
    using web services or make all of our database fields not nullable, and
    provide default values?

    Very disappointing.

    Jeff
     
    OhioGolfer, Nov 10, 2005
    #5
  6. Hi Jeff,

    I'm sorry, but currently there is nothing we can do on this issue. I
    suggest you try to contact Microsoft PSS for more information on this issue
    to see if they can work out a fix for you. Here is their contact
    information.

    http://support.microsoft.com/default.aspx?scid=fh;EN-US;OfferProPhone

    Kevin Yu
    =======
    "This posting is provided "AS IS" with no warranties, and confers no
    rights."
     
    Kevin Yu [MSFT], Nov 11, 2005
    #6
  7. OhioGolfer

    OhioGolfer Guest

    Kevin (and any others who may encounter this issue):

    After much agonizing and trial and error, I have found a workaround
    that enables the client to capture the nullValue attributes.

    Assuming a typed datset named myData, generate the dataset. In the
    myData.vb file, modify the Init_Class procedure for each datatable in
    your dataset by including the following for any nullable fields. (Here
    I am assuming fields called myString, myInt, myDate):
    columnmyString.ExtendedProperties.Add("nullValue","_empty")
    columnmyInt.ExtendedProperties.Add("nullValue","0")
    columnmyDate.ExtendedProperties.Add("nullValue,"2000-01-01")

    Save the myData.vb file. Delete any existing web references that call
    for the myData schema, and create a new web reference. If you check
    the myData.xsd file generated, as well as the Reference.vb file, you
    will see that the attributes are preserved, and the calls to the
    StrongTypingException in the Reference.vb file no longer exist.

    One caveat here is that this should be done after you have finalized
    the structure of your typed dataset. Regenerating the .xsd file on the
    server will regenerate the .vb file on the server, and you will have to
    add the ExtendedProperties again.

    Hope this helps others. Is Microsoft fixing this in 2.0?

    Jeff






    Kevin Yu [MSFT] wrote:
    > Hi Jeff,
    >
    > I'm sorry, but currently there is nothing we can do on this issue. I
    > suggest you try to contact Microsoft PSS for more information on this issue
    > to see if they can work out a fix for you. Here is their contact
    > information.
    >
    > http://support.microsoft.com/default.aspx?scid=fh;EN-US;OfferProPhone
    >
    > Kevin Yu
    > =======
    > "This posting is provided "AS IS" with no warranties, and confers no
    > rights."
     
    OhioGolfer, Nov 12, 2005
    #7
  8. Hi Jeff,

    Thanks for your workaround. So far, I didn't see .NET 2.0 framework has
    fixed this yet.

    Kevin Yu
    =======
    "This posting is provided "AS IS" with no warranties, and confers no
    rights."
     
    Kevin Yu [MSFT], Nov 15, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nedu N
    Replies:
    1
    Views:
    1,801
    Chris Taylor
    Oct 31, 2003
  2. Nedu N
    Replies:
    2
    Views:
    2,160
  3. socamb
    Replies:
    2
    Views:
    619
    socamb
    Apr 3, 2008
  4. James E

    Typed Dataset schema not showing in WSDL

    James E, Jul 15, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    143
    James E
    Jul 15, 2004
  5. Whoever
    Replies:
    6
    Views:
    159
    Whoever
    Nov 18, 2004
Loading...

Share This Page