Related:
- Connectivity with sql server 2008 from visual
- Wvm visual novel - Download - Adult games
- Cybera server - Download - Business management
- Oracle sql datediff - Guide
- Soundwire server - Download - Other
- Visual paradigm download - Download - Data management
1 response
Well, here's a basic call for a stored procedure, that takes no parameters and returns an XML file. Please let me know if you need other kinds of stored procedure calls:
private XmlDocument RunProcedure(string storedProcedureName, string dbConnectionString)
{
XmlDocument result = new XmlDocument();
try
{
using (SqlConnection connection = new SqlConnection(dbConnectionString))
{
connection.Open();
using (SqlCommand command = connection.CreateCommand())
{
command.CommandText = storedProcedureName;
command.CommandType = CommandType.StoredProcedure;
XmlReader reader = command.ExecuteXmlReader();
if (reader.Read())
{
result.LoadXml(reader.ReadOuterXml());
}
}
}
}
catch
{
// manage exception
}
return result;
}
private XmlDocument RunProcedure(string storedProcedureName, string dbConnectionString)
{
XmlDocument result = new XmlDocument();
try
{
using (SqlConnection connection = new SqlConnection(dbConnectionString))
{
connection.Open();
using (SqlCommand command = connection.CreateCommand())
{
command.CommandText = storedProcedureName;
command.CommandType = CommandType.StoredProcedure;
XmlReader reader = command.ExecuteXmlReader();
if (reader.Read())
{
result.LoadXml(reader.ReadOuterXml());
}
}
}
}
catch
{
// manage exception
}
return result;
}