nikhichavan502
nikhichavan502

Reputation: 27

Where to create web service or wcf service for accessing SQL Server 2012 data

As I am new to web service and WCF too I don't know where to create web service (or WCF) for accessing SQL Server 2012 data.

Is there any tool to create web service like Visual Studio 2010 (maybe but I don't know)? If yes then how to create it in Visual Studio suggest any solution.

If there is any code of web service or WCF service to access SQL Server 2012 data then please post or link it or if possible send the zip of it

Upvotes: 0

Views: 1758

Answers (2)

nomail
nomail

Reputation: 650

You can try to use this framework Nelibur. Just modify an example according to your needs.

Official site: Nelibur.org

Here is an idea to get you started

public sealed class ClientProcessor : IPostWithResponse<CreateClientRequest>,
                                IGetWithResponse<GetClientRequest>,
                                IDelete<DeleteClientRequest>,
                                IPutWithResponse<UpdateClientRequest>
{


       public object GetWithResponse(GetClientRequest request)
       {        
          string connectionString = "Data Source=.;Initial Catalog=MyDatabase;Integrated Security=SSPI;";
          using (SqlConnection connection = new SqlConnection(connectionString)) {
              using (SqlCommand command = new SqlCommand("SELECT * FROM Clients WHERE Id=request.Id", connection)) {
                 connection.Open();
                 Client client = ...read from database here...
               }
          }
   return client;
  }

... other methods ...
}

Upvotes: 4

Sajeetharan
Sajeetharan

Reputation: 222532

Here is a simplet example to learn WCF step by step with backend,

WCF Service to Insert,Delete and Update

Upvotes: 0

Related Questions