当前位置:编程学习 > C#/ASP.NET >>

看看国外的一个操作XML的东西。很不错。一、System.Data.XmlClient - XmlCommand

答案:using System;
using System.ComponentModel;
using System.Data;
using System.Xml;

namespace System.Data.XmlClient
{

  public class XmlCommand : Component, IDbCommand, ICloneable
    {
    // Constructors
    public XmlCommand()
        {
        }

    public XmlCommand(string sCommand)
    {
      _commandText = sCommand;
      _connection = null;
    }

    public XmlCommand(string sCommand, XmlConnection conn)
    {
      _commandText = sCommand;
      _connection = conn;
    }

    ////////////////////
    // IDbCommand
    ////////////////////

    // Public Properties
    public string CommandText
    {
      get { return _commandText;  }
      set { _commandText = value; }
    }

    public int CommandTimeout
    {
      get { throw new InvalidOperationException("XmlClient Provider does not support this property"); }
      set { throw new InvalidOperationException("XmlClient Provider does not support this property"); }
    }

    public CommandType CommandType
    {
      get { throw new InvalidOperationException("XmlClient Provider does not support this property"); }
      set { throw new InvalidOperationException("XmlClient Provider does not support this property"); }
    }

    public IDbConnection Connection
    {
      get { return _connection;  }
      set { _connection = (XmlConnection) value; }
    }

    public IDataParameterCollection Parameters
    {
      get { throw new InvalidOperationException("XmlClient Provider does not support this property"); }
    }

    public IDbTransaction Transaction
    {
      get { throw new InvalidOperationException("XmlClient Provider does not support this property"); }
      set { throw new InvalidOperationException("XmlClient Provider does not support this property"); }
    }

    public UpdateRowSource UpdatedRowSource
    {
      get { throw new InvalidOperationException("XmlClient Provider does not support this property"); }
      set { throw new InvalidOperationException("XmlClient Provider does not support this property"); }
    }

    // Public Methods
    public void Cancel()
    {
      throw new InvalidOperationException("XmlClient Provider does not support this function");
    }

    public IDbDataParameter CreateParameter()
    {
      throw new InvalidOperationException("XmlClient Provider does not support this function");
    }

    public int ExecuteNonQuery()
    {
      throw new InvalidOperationException("XmlClient Provider does not support this function");
    }

    public IDataReader ExecuteReader()
    {
      return null;
    }

    public IDataReader ExecuteReader(CommandBehavior behavior)
    {
      return null;
    }

    public object ExecuteScalar()
    {
      throw new InvalidOperationException("XmlClient Provider does not support this function");
    }

    public void Prepare()
    {
      //throw new InvalidOperationException("XmlClient Provider does not support this function");
    }

    ////////////////////
    // ICloneable
    ////////////////////
    public object Clone()
    {
      return null;
    }

    ////////////////////
    // Internal Data Members
    ////////////////////
    internal string _commandText = "";
    internal XmlConnection _connection = null;
     }
}

上一个:XmlDataAdapter
下一个:使用XML的五种场合(转)

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,