Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Convert raw byte[8192] of SQL Server XML datatype into a C# string?

Convert raw byte[8192] of SQL Server XML datatype into a C# string?

Scheduled Pinned Locked Moved Database
databasecsharpasp-netsql-servercom
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arnold_w
    wrote on last edited by
    #1

    I'm trying to get the project GitHub - improvedk/OrcaMDF: A C# parser for MDF files. Allows you to read tables, metadata and indexes from MDF files without it being attached to a running SQL Server instance.[^] to work with the XML SQL Server data type. When I step in the debugger, I can see that I receive an array byte[8192] with XML-data (each ASCII character seems to occupy 2 bytes) in the file \OrcaMDF\src\OrcaMDF.Core\Engine\Records\TextRecord.cs:line 35. Does anybody know how I can retrieve the proper XML-string? I guess the start index and length of the string must be baked into the array somehow.

    P 1 Reply Last reply
    0
    • A arnold_w

      I'm trying to get the project GitHub - improvedk/OrcaMDF: A C# parser for MDF files. Allows you to read tables, metadata and indexes from MDF files without it being attached to a running SQL Server instance.[^] to work with the XML SQL Server data type. When I step in the debugger, I can see that I receive an array byte[8192] with XML-data (each ASCII character seems to occupy 2 bytes) in the file \OrcaMDF\src\OrcaMDF.Core\Engine\Records\TextRecord.cs:line 35. Does anybody know how I can retrieve the proper XML-string? I guess the start index and length of the string must be baked into the array somehow.

      P Offline
      P Offline
      phil o
      wrote on last edited by
      #2

      You could try

      string xml = System.Text.UnicodeEncoding.GetString(theByteArray);

      If this does not produce proper result, you could also try one of other encodings provided by the framework: Encoding Class (System.Text) | Microsoft Docs[^].

      "Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups