第2个回答 2008-08-07
// Create the connection.
string constr = "User Id=scott;Password=tiger;Data Source=oracle";
OracleConnection con = new OracleConnection(constr);
con.Open();
// Create the command.
OracleCommand cmd = con.CreateCommand();
// Set the XML command type to query.
cmd.XmlCommandType = OracleXmlCommandType.Query;
// Change the SQL query, and set the maximum number of rows to 2.
cmd.CommandText = "select * from emp e";
// Set the XML query properties.
cmd.XmlQueryProperties.MaxRows = 2;
cmd.XmlQueryProperties.RootTag = "ROWSET";
cmd.XmlQueryProperties.RowTag = "ROW";
Stream stream = cmd.ExecuteStream();
// 将这个Stream写到XML文件里就可以了,这步相信对你来说很容易本回答被网友采纳