473,405 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

DataSet DateTime Format

I have seen this problem posted all over, but have never ran across a
solution....
I am serializing my dataset and they look like this:

<NewDataSet>
<xs:schema id="NewDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true"
msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="List_101">
<xs:complexType>
<xs:attribute name="InvoiceID" type="xs:int" />
<xs:attribute name="Email" type="xs:string" />
<xs:attribute name="DomainID" type="xs:int" />
<xs:attribute name="SourceID" type="xs:int" />
<xs:attribute name="TypeEnum" type="xs:int" />
<xs:attribute name="ImportID" type="xs:int" />
<xs:attribute name="DateStamp" type="xs:dateTime" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<List_101 EmailID="InvoiceID" Em************@joe.com DomainID="2421"
SourceID="12" TypeEnum="2" ImportID="20"
DateStamp="2005-09-18T17:39:00-07:00" />
</NewDataSet>

This blows up in SQL when I call "sp_xml_preparedocument".
It has trouble converting the DateStamp (because of the format)...
If I put it in Query Analyzer and remove "-07:00" from the DateStamp it
works fine....

How do I get rid of that? I don't want to parse every file that I export,
because I'm doing a ton of them.
Is there something I can do to the DataSet??? I tried things such as:
ds.Locale = CultureInfo.InvariantCulture;
But that doesn't work, and I don't know why it would because I don't even
know what that means. I thought the "-07:00" offset might be a culture
thing....nope....

Does anyone have any ideas?
Jan 11 '06 #1
3 9010
Has anyone else run across this?

Jan 11 '06 #2
Although I didn't "solve" the problem, I figured out how to work around it.
If you paste this in Query Analyzer it should work:
---------------------------------------
declare @x nvarchar(4000)
Select @x = N'<NewDataSet>
<xs:schema id="NewDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true"
msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="List_101">
<xs:complexType>
<xs:attribute name="InvoiceID" type="xs:int" />
<xs:attribute name="Email" type="xs:string" />
<xs:attribute name="DomainID" type="xs:int" />
<xs:attribute name="SourceID" type="xs:int" />
<xs:attribute name="TypeEnum" type="xs:int" />
<xs:attribute name="ImportID" type="xs:int" />
<xs:attribute name="DateStamp" type="xs:dateTime" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<List_101 InvoiceID="19066" Email="jo*@joe.com" DomainID="2421"
SourceID="12" TypeEnum="2" ImportID="20"
DateStamp="2065-09-18T17:39:00-07:00" />
</NewDataSet>'

Declare @hDoc int
exec sp_xml_preparedocument @hDoc OUTPUT, @x
-- Insert Into List_101
Select
InvoiceID, Email, DomainID, SourceID, TypeEnum, ImportID,
CAST(left(DateStamp,10) AS datetime)
From
OPENXML(@hDoc, '/NewDataSet/List_101')
WITH (
InvoiceID Integer,Email varchar(50),DomainID Integer,SourceID
Integer,TypeEnum Integer,ImportID Integer,DateStamp varchar(10))

Exec sp_xml_removedocument @hDoc
---------------------------------------

I was trying to insert the XML data into a table called List_101, and that
table has a 'DateStamp' column that is a datetime type.
I kept getting the "Syntax error converting datetime from character string."
because of the DateTime format from DataSet.WriteXML();

So I ended up using the CAST(left(DateStamp,10) AS datetime) so it was in
the correct format and changed the WITH to DateStamp varchar(10).
The sp_xml_preparedocument doesn't blow up anymore and the data gets
successfuly inserted into List_101 with the proper DateStamp (which is a
datetime in the table) because it converts the varchar(10) on its own.

Hopefully this helps the next person.
Jan 11 '06 #3
I also published the solution here:

http://ineedadip.blogspot.com/2006/0...e-problem.html
Jan 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: andrewcw | last post by:
I read in a earlier post that I can get the column of a grid to sort by datetime if the column type was set as Date I deserialize my XML and one attribute of the XSD has type as dateTime but upon...
0
by: vooose | last post by:
Suppose you have a DataTable which is part of a DataSet that has a column of type DateTime. When you call ds.GetXml() the date comes out looking something like this: ...
6
by: Helen | last post by:
I have an array being passed as a parameter to Crystal 9 (using vb .net in VS 2002). The listbox containing the dataset output at runtime shows DateTime format, but I want to only show mm/dd/yyyy...
26
by: Reny J Joseph Thuthikattu | last post by:
Hi, I have a variabe in the format of 'DD-MON-YYYY HH:MI AM' .I want to add a miniute to it.How can i do that? by manipulation i want to make '01-JUNE-2004 11:59 PM' to '02-JUNE-2004 12:00 AM'...
1
by: Scott M. Lyon | last post by:
Part of an application I'm working on needs to manipulate some XML data (in an XML file), by reading the data into a DataSet using the MyDataSet.ReadXML method, and then using MyDataSet.WriteXML to...
3
by: darrel | last post by:
I'm grabbing an XML string from a database and trying to pass it into a dataset. I've read this article: http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=213 and have tried to implement it as...
0
by: samtilden | last post by:
We have upgraded our web project to Visual Studio 2005 (from VS 2003) and are still interfacing with some legacy ASP code that we do not want to change. The problem is that the VS 2003 compiler...
4
by: LW | last post by:
Hi! I have a DataSet and a class in my Web Service. My output for example is: <OrderInfo> <CustomerID>VINET</CustomerID> <OrderID>10248</OrderID> <OrderDate>07/07/1996</OrderDate>...
1
by: | last post by:
I'm querying Index Server to return search results, both regular properties and some custom properties I've created. Index Server has this preference for thinking about information as strings...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.