SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
SqlCommand cmd = (SqlCommand)db.GetStoredProcCommand(“usp_GetProjects_XML”);
db.AddInParameter(cmd, “AirID”, SqlDbType.Int, airID);
XmlReader xmlRdr = null;
StringBuilder sbData = new StringBuilder();
try
{
xmlRdr = db.ExecuteXmlReader(cmd);
while (!xmlRdr.EOF)
{
if (xmlRdr.IsStartElement())
{
sbData.Append(xmlRdr.ReadOuterXml());
sbData.Append(Environment.NewLine);
}
}
}
finally
{
if (xmlRdr != null)
{
xmlRdr.Close();
}
// Explicitly close the connection. The connection is not closed
// when the XmlReader is closed.
if (cmd.Connection != null)
{
cmd.Connection.Close();
}
}
return = sbData.ToString();