Web方法中的数据类型 [英] datatype in web method

查看:96
本文介绍了Web方法中的数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<root>
<value pid="AN_PW_ID_2" name="aaaa" phoneno="1234567890" address="Somewhere" />
<value pid="AN_PW_ID_2" name="bbbb" phoneno="1234567890" address="Somewhere" />
</root>


上面的标记是我的Web方法的输入,应该作为输入参数传递给sql存储过程.

这个怎么做.

上面的输入要声明的数据类型是什么,以及如何将此输入传递给我的存储过程?

请在这方面帮助我.

在此先感谢.


The above tags is the input for my web method and this should be passed as input parameter to sql stored procedure.

How to do this.

What is the datatype to be declared for the above input and how to pass this input to my stored procedure?

Kindly help me in this.

Thanks in advance.

推荐答案

执行以下代码以获取XML内容并执行相关的SQL存储过程,如下所示:

Execute the below code to fetch XML content and execute the relevant SQL stored procedure as:

XmlTextReader reader = new XmlTextReader(strPassedXML);
while (reader.Read())
{
    switch (reader.NodeType)
    {
    case XmlNodeType.Element:
        Hashtable attributes = new Hashtable();
        string strURI= reader.NamespaceURI;
        string strName= reader.Name;
        if (reader.HasAttributes)
        {
            for (int i = 0; i < reader.AttributeCount; i++)
            {
               strSQL = "exec spSample '" & reader.GetAttribute("pid")
                      & "'  '" & reader.GetAttribute("name")
                      & "'  '" & reader.GetAttribute("phoneno")
                      & "'  '" & reader.GetAttribute("address") & "'"

               SqlCommand cmd  = new SqlCommand(strSQL, conn);
               cmd.CommandType = CommandType.StoredProcedure;
               cmd.ExecuteReader();
        }
    }
}


这篇关于Web方法中的数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆