毛毛的小窝 — 关注技术交流、让我们一起成长

导航

(原) ODP.NET 演示如何使用 OracleXmlQueryProperties 类

using System;
using System.Collections.Generic;
using System.Text;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;

namespace XmlProp11
{
    
// 演示如何使用 OracleXmlQueryProperties 类
    class Program
    
{
        
static void Main(string[] args)
        
{
            
// Create the connection.
            string constr = "User Id=scott;Password=tiger;Data Source=bjoracle)";
            OracleConnection conn 
= new OracleConnection(constr);
            conn.Open();

            
// Create the command
            OracleCommand cmd = new OracleCommand("", conn);

            
// Set the XML properties directly on xml query properties
            
// of the OracleCommand object
            Console.WriteLine("Set the properties directly on OracleCommand object.");

            Console.WriteLine(
"Set row tag to ROW");
            cmd.XmlQueryProperties.RowTag 
= "ROW";
            Console.WriteLine(
"Row tag: " + cmd.XmlQueryProperties.RowTag);

            Console.WriteLine(
"Set row tag to EMPLOYEE.");
            cmd.XmlQueryProperties.RowTag
="EMPLOYEE";
            Console.WriteLine(
"Row tag: " + cmd.XmlQueryProperties.RowTag);

            Console.WriteLine(
"\n");

            
// Set the XML properties using an OracleXMLQueryProperties object
            Console.WriteLine("Set the XML properties using an OracleXmlQueryProperties object.");
            OracleXmlQueryProperties qprops 
= new OracleXmlQueryProperties();

            Console.WriteLine(
"Set row tag to ROW on OracleXmlQueryProperties object.");
            qprops.RowTag
="Row";

            Console.WriteLine(
"Set the new XmlQuery properties on the OracleCommand.");
            cmd.XmlQueryProperties
=qprops;

            Console.WriteLine(
"Set the tag to EMPLOYEE on OracleXmlQueryProperties object.");
            qprops.RowTag
="EMPLOYEE";

            Console.WriteLine(
"Row tag on OracleXmlQueryProperties object: " +qprops.RowTag);
            Console.WriteLine(
"Row tag on OracleCommand object: " + cmd.XmlQueryProperties.RowTag);
            Console.WriteLine(
"\n");

            Console.WriteLine(
"Set row tag to ROW on OracleCommand object.");
            cmd.XmlQueryProperties.RowTag
="ROW";

            
// Clone the XmlQueryProperties from the OracleCommand object.
            Console.WriteLine("Clone the XmlQueryProperties from the OracleCommand object.");
            OracleXmlQueryProperties qpropsClone 
= (OracleXmlQueryProperties)cmd.XmlQueryProperties.Clone();

            Console.WriteLine(
"Row tag on OracleCommand object: " + cmd.XmlQueryProperties.RowTag);
            Console.WriteLine(
"Row tag on Cloned OracleXmlQueryProperties object: " + qpropsClone.RowTag);
            Console.WriteLine(
"\n");

            
// Clone the OracleCommand object.
            Console.WriteLine("Clone the OracleCommand object.");
            OracleCommand cmdClone 
= (OracleCommand)cmd.Clone();

            Console.WriteLine(
"Set row tag to EMPLOYEE on OracleCommand object.");
            cmd.XmlQueryProperties.RowTag
="EMPLOYEE";

            Console.WriteLine(
"Row tag on OracleCommand object: " + cmd.XmlQueryProperties.RowTag);
            Console.WriteLine(
"Row tag on Cloned OracleCommand object: " + cmdClone.XmlQueryProperties.RowTag);
            Console.WriteLine(
"\n");

            
// Clean up
            cmd.Dispose();
            cmdClone.Dispose();
            conn.Close();
            conn.Dispose();

            
// waiting
            Console.ReadLine();

        }

    }

}


OracleXmlQueryProperties 类介绍

MaxRows  返回的数据集中最大的行数
RootTag  XML 文档的跟标签
RowTag  XML 元素值说明
Xslt  XML 文档转换的 XSLT 说明
XsltParams  XSL document 参数说明

Clone()  OracleXmlQueryProperties object 的拷贝

posted on 2007-12-28 16:37  mjgforever  阅读(344)  评论(0编辑  收藏  举报