Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 xml parsing error

Author  Topic 

cbeganesh
Posting Yak Master

105 Posts

Posted - 2005-06-01 : 11:52:54
Im trying to load an xml document to sql server using sp_xml_preparedocument . The xml document has utf-8 as encoding. Im getting this error
"System.Data.SqlClient.SqlException: XML parsing error: Switch from current encoding to specified encoding not supported"

Any help on this is appreciated

raclede
Posting Yak Master

180 Posts

Posted - 2005-06-02 : 00:58:22
My suggestion if to create an SP that will execute the sp_xml_preparedocument command, and this
SP just call it in .NET

"If the automobile had followed the same development cycle as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year, killing everyone inside. "

raclede
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2005-06-02 : 01:04:44
It looks like that is what he is doing raclede.


Damian
Ita erat quando hic adveni.
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2005-06-02 : 02:24:53
quote:
Originally posted by cbeganesh

Im trying to load an xml document to sql server using sp_xml_preparedocument . The xml document has utf-8 as encoding. Im getting this error
"System.Data.SqlClient.SqlException: XML parsing error: Switch from current encoding to specified encoding not supported"

Any help on this is appreciated



How are you doing this exactly? Can you post some of your code?

Also, are you using unicode datatypes for variables in your code?


-ec
Go to Top of Page

raclede
Posting Yak Master

180 Posts

Posted - 2005-06-02 : 02:50:19
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50531

"If the automobile had followed the same development cycle as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year, killing everyone inside. "

raclede
Go to Top of Page

cbeganesh
Posting Yak Master

105 Posts

Posted - 2005-06-02 : 09:30:43
Yes, From DOT NET, Im creating the xml document and the output xml has encoding="utf-8". Im calling a stored procedure from dot net that used sp_xml_prepared document and then inserting into table using open xml. If i remove the encoding="utf-8" from the xml document, It works fine.
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2005-06-02 : 10:17:50
quote:
Originally posted by cbeganesh

Yes, From DOT NET, Im creating the xml document and the output xml has encoding="utf-8". Im calling a stored procedure from dot net that used sp_xml_prepared document and then inserting into table using open xml. If i remove the encoding="utf-8" from the xml document, It works fine.



are you using unicode datatypes on the sql server side? specifically, are you using an ntext datatype?


-ec
Go to Top of Page

cbeganesh
Posting Yak Master

105 Posts

Posted - 2005-06-02 : 11:31:44
yes Im getting the xmldocument as ntext datatype
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2005-06-02 : 13:23:39
quote:
Originally posted by cbeganesh

yes Im getting the xmldocument as ntext datatype



Well, if you want any real help from the group here you are going to have to post some code.

Usually and error like this is due to not using unicode datatypes, but you indicate that you are.



-ec
Go to Top of Page

cbeganesh
Posting Yak Master

105 Posts

Posted - 2005-06-02 : 14:41:07
Here is the code

ALTER PROCEDURE uspInsertXml (@FileContents ntext)
AS

DECLARE @iDoc int
DECLARE @FileName varchar(255)
DECLARE @ExecCmd VARCHAR(255)
DECLARE @y INT
DECLARE @x INT


EXECUTE sp_xml_preparedocument @iDoc OUTPUT, @FileContents

SELECT * INTO #JOBS FROM OpenXML(@iDoc, 'job/jobHeader', 2)
WITH
(version float,
ProfileId int,
jobNumber varchar(25),
email varchar(100),
dateFrom varchar(10),
dateTo varchar(10),
jobType varchar(1)
)

EXECUTE sp_xml_removedocument @iDoc
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2005-06-02 : 18:06:53
you aren't using unicode datatypes in your WITH schema declaration.



-ec
Go to Top of Page

cbeganesh
Posting Yak Master

105 Posts

Posted - 2005-06-03 : 09:51:48
you mean to change the columns datatype to ntext
Go to Top of Page
   

- Advertisement -