Calling a Stored Procedure with XML Datatype

前端 未结 9 1239
旧巷少年郎
旧巷少年郎 2021-01-05 07:06

I am simply trying to call a store procedure (SQL Server 2008) using C# and passing XMLDocument to a store procedure parameter that takes a SqlDbType.Xml data type. I am ge

9条回答
  •  日久生厌
    2021-01-05 07:55

    public static string SerializeToXml(T obj)
    {
        XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
    
        ns.Add("","");
    
        StringWriter Output = new StringWriter(new StringBuilder());
        XmlSerializer ser = new XmlSerializer(obj.GetType);
        ser.Serialize(Output, obj, ns);
    
        return Output.ToString();
    }
    

提交回复
热议问题