CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Location
    Montreal (CA)
    Posts
    5

    DataSet with XML source and schema

    Hi,

    I need to use a DataSet with an XML source and an XML schema to fill a DataGrid.
    In my schema, I have a date element (<xs:element name="date" type="xs:date"/>)

    When I load the DataGrid with the DataSet, all my dates are showed like a date type.
    After some changes, when I get my data from the DataSet (with MyDataSet.GetXml()), all my dates are datetime type even I specify "xs:date" in my schema.

    date format : 2004-07-19
    datetime format : 2004-07-19T14:43:25.6550000-04:00

    Does anybody has an idea?
    If you need some explanation, I can send you a big part of code.

    Thanks

    Gérard

  2. #2
    Join Date
    May 2002
    Location
    Russia
    Posts
    1,571
    Quote Originally Posted by frag0610
    After some changes, when ...
    What changes?
    Quote Originally Posted by frag0610
    If you need some explanation, I can send you a big part of code.
    Please.

  3. #3
    Join Date
    Jul 2004
    Location
    Montreal (CA)
    Posts
    5

    Changes

    The changes are addition of new rows in DataGrid or modification of existing rows.

    I have done the following test yesterday:
    - I have added the schema to the DataSet (with ReadXmlSchema) and I have filled it with the XML source (with ReadXml).
    - After this, I have executed (without change to the data) a GetXml in the Visual Studio command window. The result was that my dates had been changed to datetime.

    Thanks for your time.

    Gérard

  4. #4
    Join Date
    May 2002
    Location
    Russia
    Posts
    1,571
    The pattern for date is CCYY-MM-DD with optional time zone indicator as allowed for dateTime.

    So it is date nevertheless.

  5. #5
    Join Date
    Jul 2004
    Location
    Montreal (CA)
    Posts
    5

    Part of code

    My problem is that I do not know the content (data and data type) of the DataSet ... so I am not sure that it will have a date inside.
    The display in the DataGrid is correct. I think that the problem is only the DataSet.

    When I see the type of DataSet columns in the debugger, the columns are always from System.DateTime type because the System.Date type does not exist !
    I think that I need to check the elements type in the schema, to transform, if necessary, the data in good format.


    This is a part of the code I use:

    Dim oXmlTR As New XmlTextReader(MyXMLData)

    If MyXSDFileName <> "" Then
    'Add schema to DataSet
    DataSet1.ReadXmlSchema(MyXSDFileName)
    End If

    'I don't need namespace in my application
    DataSet1.Namespace = ""

    'Add data to DataSet
    DataSet1.ReadXml(oXmlTR)


    Thanks for your time

    Gérard

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

Featured