Microsoft Office Tutorials and References
In Depth Information
WCF Service Library (and Interface) Class (Listings 2-3 and 2-4)
Consider this a data –access-layer class that calls the uspGetServerDetails stored procedure and returns
the output as a data table.
When the WCF application project is created, a service class and corresponding interface template are added
to the project. Declare the Service Contract and Operation Contract (as shown next) interface classes that will
be implemented in your derived class. Because the intention is to retrieve a data table from this service,
the data contract method will be of type DataTable .
public interface IServerStatus
DataTable GetServerStatusDetails();
Under the derived class in the implemented method GetServerStatusDetails , create the data objects needed
for the output:
DataSet dataSet = new DataSet();
Next, create the sQL Connection using the connection string from Web.config:
SqlConnection connection = new SqlConnection(
Create the command object by calling the stored procedure with the help of the sQL Connection, and set the
command type to StoredProcedure :
SqlCommand command = new SqlCommand("uspGetServerDetails", connection);
command.CommandType = CommandType.StoredProcedure;
Finally, create the data adapter, load the command, and fill the data set using the data adapter:
SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
Close the connection, and return the output:
return dataSet.Tables[0];
if you are a novice WCF developer, simply start from here: .
Search JabSto ::

Custom Search