Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 

Go Back   XSL - XML - RSS Forums > XML General > SQL and XML

Tags:



Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-16-2008, 05:29 PM
FrankyDM
 
Posts: n/a

Default Error: "Index was outside the bounds of the array." in Sql Mng Stu



Sql Server 2008 Standard:

To isolate the problem I'm having, I've created a simple Dbs with just one
table, having an "int" field and an "xml" field.

The xml field is assigned to a SchemaCollection, so it is typed.
Updating the xml field with XML data works 99.99 of the times, but I have 2
specific XML fragments that systematically give me problems. Updating the xml
field in the table with this data works fine without errors, however when I
do a SELECT * from the table in the Management Studio, I get the error:

"An error occurred while executing batch. Error message is: Index was
outside the bounds of the array."

Changing "SELECT xmlField FROM tab" to "SELECT CAST(xmlField AS
nvarchar(MAX)) FROM tab" appears to give me the correct xml string, so the
data is there!

Querying the data from .Net code gives the same error. Here's part of the
stack trace:

[IndexOutOfRangeException: Index was outside the bounds of the array.]
System.Xml.XmlSqlBinaryReader.GetXsdKatmaiTokenLen gth(BinXmlToken token)
+1207761
System.Xml.XmlSqlBinaryReader.ScanOverAnyValue(Bin XmlToken token, Boolean
attr, Boolean checkChars) +524
System.Xml.XmlSqlBinaryReader.ScanOverValue(BinXml Token token, Boolean
attr, Boolean checkChars) +159
System.Xml.XmlSqlBinaryReader.ImplReadData(BinXmlT oken tokenType) +119
System.Xml.XmlSqlBinaryReader.ReadDoc() +589
System.Xml.XmlSqlBinaryReader.Read() +201

I get this exact problem on different machines: both the production Server
2003 and my Vista development PC.

I've been successfully using XML fields in SQL2005 for 3 years now, and have
recently upgraded to SQL2008.

This has me completely puzzled.
Is there any known problem that might be related or anyone has a queue how
to fix this? Would be warmly appreciated.

Thanks
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-20-2008, 06:59 PM
FrankyDM
 
Posts: n/a

Default RE: Error "Index was outside the bounds of the array." in SqlMngStudio

OK, I have managed to create a "repro" script.

Just download the following:

http://www.eazign.be/Temp/SqlRepro.sql.zip

Contains only 1 file: SqlRepro.sql
Run this script on any SQL Server 2008 (I use the Standard version).

What the script does:
1. Create a new database: "FdmSqlRepro" (drops it first if already exists)
2. Create a schema collection: "MySchemaCollection"
3. Create a table: "TestTable", with a numeric "idx" column and a typed xml
column "xData". The xml column is bound to the created "MySchemaCollection"
4. Insert 1 record in the table
5. Query the table (SELECT * FROM TestTable)

That's all!

The last step (query *) gives the error:
"Index was outside the bounds of the array."

Can anyone run this script and confirm they get the same error?
And then of course: why does it happen ... ? Any workarounds?

Many thanks in advance,
Hopefully my question is a little more documented now
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Contact Us -|- XSL - XML - RSS Forums -|- Archive -|- Top -|-Rules/Disclaimer-|-Help/Support -|-Advertise
© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
All times are GMT. The time now is 09:50 AM.
Style Developed by Epic Designz