C#/SQL - What's wrong with SqlDbType.Xml in procedures?

前端 未结 3 938
走了就别回头了
走了就别回头了 2020-12-07 01:55

I\'ve asked few people why using xml as a parameter in stored procedure doesn\'t work and everyone said , that\'s just the way it is. I can\'t belive that.

c         


        
3条回答
  •  不知归路
    2020-12-07 02:40

    //Create The StringWriter Object
    
    var stringWriter = new System.IO.StringWriter();
    
    //Create XmlSerializer Object for the serialization,
    RequestUpdateRBCustomerExternal is the Class of which type having all the values
    
    var serializer = new XmlSerializer(typeof(RequestUpdateRBCustomerExternal));
    
    //request is of type RequestUpdateRBCustomerExternal
    
    serializer.Serialize(stringWriter, request);
    
    SqlXml xml = new SqlXml(new XmlTextReader(stringWriter.ToString(), XmlNodeType.Document, null));
    
    cmd.CommandText ="insert into SAPDataTracking values('"+DateTime.Now+"','"+xml.Value+"')";
    

提交回复
热议问题