VB.NET•Conform SQLXML 3.0 DataSets to the .NET 1.1 Schema

Listing 1. SQLXML 3.0 Web services created from stored procedures return DataSet streams with <rowset> as the root element name and an extra minOccurs="0" maxOccurs="79228162514264337593543950335" attribute. This code changes <rowset> to <NewDataSet> and removes the spurious attribute to conform the document structure to that returned by invoking the SqlDataAdapter.Fill() method.

Dim stmFile As StreamReader = _
   File.OpenText(strFile)
strText = stmFile.ReadToEnd
stmFile.Close()
'Fix up the root element name and conform the
'schema to the DataAdapter.Fill operation
Dim sbFile As New StringBuilder
sbFile.Append(strText)
sbFile.Replace("rowset", "NewDataSet")
Dim strReplace As String = "minOccurs=""0""" + _
   "maxOccurs=""79228162514264337593543950335"""
sbFile.Replace(strReplace, "")
'Write the file
Dim stmWrite As New StreamWriter(strFile, False)
stmWrite.Write(sbFile.ToString)
stmWrite.Close()
'Clear the DataSet and read the modified file
dsCusts.Clear()
dsCusts.ReadXml(strFile, XmlReadMode.ReadSchema)
'Accepting all changes is very important at this 
'point
dsCusts.AcceptChanges()