G
Guest
I have a web method that I want to improve by using the Enterprise Library
Data block. I have added the Microsoft.Practices.EnterpriseLibrary.Data.dll
and Microsoft.Practices.EnterpriseLibrary.Data.xml references to my project
but I can't work out how to use them. The Help is confusing and I can't find
any examples anywhere.
Please can someone tell me how to convert the following code? It is
written in Visual Studio 2005 in C# and it works correctly as it is. It
connects to a SQL Server 2005 database.
TIA,
Helen
// Takes xml data and stores it in a table using the connection and
SQL in the associated config file
[WebMethod]
public bool XMLFileToDatabase(String XMLText)
{
String ConnectionString;
SqlConnection XMLConnection;
SqlCommand UpdateXML;
// Connect to the database
ConnectionString =
ConfigurationSettings.AppSettings["ConnectionString"];
XMLConnection = new SqlConnection(ConnectionString);
XMLConnection.Open();
// Update the XML
UpdateXML = new SqlCommand();
UpdateXML.CommandText = ConfigurationSettings.AppSettings["SQL"];
UpdateXML.Parameters.Add("@XMLText", SqlDbType.Text).Value =
XMLText;
UpdateXML.Connection = XMLConnection;
UpdateXML.ExecuteScalar();
return true;
}
Data block. I have added the Microsoft.Practices.EnterpriseLibrary.Data.dll
and Microsoft.Practices.EnterpriseLibrary.Data.xml references to my project
but I can't work out how to use them. The Help is confusing and I can't find
any examples anywhere.
Please can someone tell me how to convert the following code? It is
written in Visual Studio 2005 in C# and it works correctly as it is. It
connects to a SQL Server 2005 database.
TIA,
Helen
// Takes xml data and stores it in a table using the connection and
SQL in the associated config file
[WebMethod]
public bool XMLFileToDatabase(String XMLText)
{
String ConnectionString;
SqlConnection XMLConnection;
SqlCommand UpdateXML;
// Connect to the database
ConnectionString =
ConfigurationSettings.AppSettings["ConnectionString"];
XMLConnection = new SqlConnection(ConnectionString);
XMLConnection.Open();
// Update the XML
UpdateXML = new SqlCommand();
UpdateXML.CommandText = ConfigurationSettings.AppSettings["SQL"];
UpdateXML.Parameters.Add("@XMLText", SqlDbType.Text).Value =
XMLText;
UpdateXML.Connection = XMLConnection;
UpdateXML.ExecuteScalar();
return true;
}