Connectivity with sql server 2008 from visual
Closed
Mani
-
Jul 20, 2009 at 02:36 AM
cyril8727 Posts 24 Registration date Monday July 21, 2008 Status Member Last seen July 20, 2009 - Jul 20, 2009 at 12:43 PM
cyril8727 Posts 24 Registration date Monday July 21, 2008 Status Member Last seen July 20, 2009 - Jul 20, 2009 at 12:43 PM
Related:
- Connectivity with sql server 2008 from visual
- Oracle sql datediff - Guide
- Wvm visual novel - Download - Adult games
- Visual paradigm - Download - Data management
- Gmail incoming mail server - Guide
- Free fire advance server - Guide
1 response
cyril8727
Posts
24
Registration date
Monday July 21, 2008
Status
Member
Last seen
July 20, 2009
1
Jul 20, 2009 at 12:43 PM
Jul 20, 2009 at 12:43 PM
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;
}