Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

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

 
   Database Help (Home) -> XML RSS
Next:  SQL Server 2005 Installation on server running SQ..  
Author Message
FrankyDM

External


Since: Oct 16, 2008
Posts: 2



(Msg. 1) Posted: Thu Oct 16, 2008 8:43 am
Post subject: Error: "Index was outside the bounds of the array." in Sql Mng Stu
Archived from groups: microsoft>public>sqlserver>xml (more info?)

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.GetXsdKatmaiTokenLength(BinXmlToken token)
+1207761
System.Xml.XmlSqlBinaryReader.ScanOverAnyValue(BinXmlToken token, Boolean
attr, Boolean checkChars) +524
System.Xml.XmlSqlBinaryReader.ScanOverValue(BinXmlToken token, Boolean
attr, Boolean checkChars) +159
System.Xml.XmlSqlBinaryReader.ImplReadData(BinXmlToken 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

 >> Stay informed about: Error: ""Index was outside the bounds of the array."" in Sql.. 
Back to top
Login to vote
FrankyDM

External


Since: Oct 16, 2008
Posts: 2



(Msg. 2) Posted: Mon Oct 20, 2008 10:35 am
Post subject: RE: Error "Index was outside the bounds of the array." in SqlMngStudio [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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

 >> Stay informed about: Error: ""Index was outside the bounds of the array."" in Sql.. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Index xml in variable - Hi, more newbie questions. When I first read over the SQLServer XML documentation, I saw you could index XML. I thought this would be great if you had a big single XML value that you were working on. I have a 2.4mb XML value now, and yeah, it's..

Distributed query and XML index - Distributed query is not supported when there is XML column in the table. So I create nvarchar column on the table and cast it to XML column in the view. However, I want to create XML index because of the performance. But XML index could not be created o...

why conversion error? - declare @cid uniqueidentifier declare @pid uniqueidentifier set @cid = '0F88363A-5689-42E1-8A1A-86228B9C23C5' set @pid = 'C8F5598F-2A72-4E8D-A833-00C9F152130D' exec dbo.sp_GetReportXml @cid,@pid go gives error "Conversion failed when converting fr...

SQLXML 3.0 SP2, SAX Parser error - Hi, I do not have experience with SQLXML but there are some very annoying errors we get: "General operational error" and "Not enough storage is available to complete the operation" Nothing in NT event log, nothing in SQL Server's ...

XSD Schema Generates Error from SQLXMLBulkLoad 4.0 - I'm trying to Bulk Load an XML file with a Schema file that maps elements to database tables/columns. I get the error: "The INSERT statement conflicted with the FOREIGN KEY constraint "fk_creditindexannexbondissuer_creditindexannexcomponent&...
   Database Help (Home) -> XML All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]