Microsoft Office Tutorials and References
In Depth Information
Note the code in Listing 2-3 is explained toward the end of this chapter in the section “Understanding the Custom
Data provider Code.”
8.
open the serverstatus.svc.cs file, and paste the code from Listing 2-3 in it.
Listing 2-3. WCF Service Library Class to Retrieve Server Status
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;
namespace WcfDataProvider
{
public class ServerStatus : IServerStatus
{
[OperationBehavior]
public DataTable GetServerStatusDetails()
{
DataSet dataSet = new DataSet();
SqlConnection connection = new SqlConnection
(ConfigurationManager.ConnectionStrings["VisioServicesConnectionString"].ConnectionString);
SqlCommand command = new SqlCommand("uspGetServerDetails", connection);
command.CommandType = CommandType.StoredProcedure;
SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
dataAdapter.Fill(dataSet);
connection.Close();
return dataSet.Tables[0];
}
}
}
Note it is a good practice to add a test project for any projects you create because this would perform the first level
of unit testing for your projects.
9.
Now copy the code in Listing 2-4, open the IServerStatus.cs file, and paste the code in it.
 
 
Search JabSto ::




Custom Search