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
I am looking for connectivity with sql server 2008 from visual web developer 2008 epress edition.
Related:

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
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;
}
0