What does the SQL Server XML datatype translate to in .NET and how do I convert it to XmlDocument?

后端 未结 4 1368
悲&欢浪女
悲&欢浪女 2021-01-01 16:39

We have a column in the database that has a type of xml. I am reading this information via the .net SqlDataReader, but I\'m not sure what to cast i

4条回答
  •  隐瞒了意图╮
    2021-01-01 17:03

    I use this method myself, using SqlCommand.ExecuteXmlReader();

    XmlDocument xdoc = new XmlDocument();
    using (SqlCommand command = new SqlCommand(queryString, connection))
    {
        XmlReader reader = command.ExecuteXmlReader();
        if (reader.Read())
        {
            xdoc.Load(reader);
        }
    }
    

提交回复
热议问题