你的代码咋个写的哦The following example creates a SqlCommand and then executes it using ExecuteXmlReader. The example is passed a string that is a Transact-SQL FOR XML SELECT statement, and a string to use to connect to the data source.public void CreateMyXmlReader(string myXmlQuery, SqlConnection myConnection)
{
SqlCommand myCommand = new SqlCommand(myXmlQuery, myConnection);
try
{
myConnection.Open(); System.Xml.XmlReader myXmlReader = myCommand.ExecuteXmlReader(); // Always close the XmlReader when finished.
myXmlReader.Close();
}
catch(Exception e)
{
System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
log.Source = "My Application";
log.WriteEntry(e.ToString());
Console.WriteLine("Exception of type {0} occurred.", e.GetType());
}
finally
{
myConnection.Close();
}
}
{
SqlCommand myCommand = new SqlCommand(myXmlQuery, myConnection);
try
{
myConnection.Open(); System.Xml.XmlReader myXmlReader = myCommand.ExecuteXmlReader(); // Always close the XmlReader when finished.
myXmlReader.Close();
}
catch(Exception e)
{
System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
log.Source = "My Application";
log.WriteEntry(e.ToString());
Console.WriteLine("Exception of type {0} occurred.", e.GetType());
}
finally
{
myConnection.Close();
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货