none
Inserting data to a database using wcf services RRS feed

  • Question

  • I have been searching and try out number of different articles regarding how to insert data using a wcf service. With every example I try I end up with errors. I need to created a wcf service and pass data to a database in a MVC 5 application. I'm currently using visual studio 2015 and sql Server 2014. If any one can put me in the right path that would be a great help.Thank you in advance
    • Moved by Kristin Xie Thursday, March 10, 2016 9:03 AM
    Wednesday, March 9, 2016 8:08 AM

Answers

  • Hi Tharindu,

    Think it in this way, suppose that you are developing MVC application. For this you have a UI end from where the user will input the data and a backed end where the logic is implemented how to insert that data to db.

    So when you develop a WCF service you have to divide you program into two part. Which are server side and client side. In the client part there will be UI from where user will input the data. In the server side your backend logic how to insert that data to db will be there and you need to find a way to server and client together so that they can both communicate.

    You could see the below tutorials as they have good explanation.

    Kudvenkat WCF tutorial

    Thanks,

    Sabah Shariq

    Wednesday, March 9, 2016 9:06 AM
  • You should have a DAL Data Access Layer sitting behind the WCF service and what is sent through to the client and back through the WCF are DTO(s).

    https://en.wikipedia.org/wiki/Separation_of_concerns

    https://en.wikipedia.org/wiki/Data_access_layer

    https://en.wikipedia.org/wiki/Data_transfer_object

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wcf

     
    Wednesday, March 9, 2016 3:19 PM
  • Inserting data into a DB really doesn't have anything to do with MVC or WCF. Ultimately you'll end up with data that needs to be inserted into the DB. The real question is what data access technology you're using: ADO.NET, EF, nHibernate, etc. You should research the approach you want to take and then post in the appopriate forums to get more help once you have some code to demonstrate.

    Michael Taylor
    http://www.michaeltaylorp3.net

    Wednesday, March 9, 2016 3:47 PM
    Moderator

All replies

  • Hi Tharindu,

    Think it in this way, suppose that you are developing MVC application. For this you have a UI end from where the user will input the data and a backed end where the logic is implemented how to insert that data to db.

    So when you develop a WCF service you have to divide you program into two part. Which are server side and client side. In the client part there will be UI from where user will input the data. In the server side your backend logic how to insert that data to db will be there and you need to find a way to server and client together so that they can both communicate.

    You could see the below tutorials as they have good explanation.

    Kudvenkat WCF tutorial

    Thanks,

    Sabah Shariq

    Wednesday, March 9, 2016 9:06 AM
  • Thank you so much Sabah. I will try those tutorials.
    Wednesday, March 9, 2016 9:27 AM
  • You should have a DAL Data Access Layer sitting behind the WCF service and what is sent through to the client and back through the WCF are DTO(s).

    https://en.wikipedia.org/wiki/Separation_of_concerns

    https://en.wikipedia.org/wiki/Data_access_layer

    https://en.wikipedia.org/wiki/Data_transfer_object

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wcf

     
    Wednesday, March 9, 2016 3:19 PM
  • Inserting data into a DB really doesn't have anything to do with MVC or WCF. Ultimately you'll end up with data that needs to be inserted into the DB. The real question is what data access technology you're using: ADO.NET, EF, nHibernate, etc. You should research the approach you want to take and then post in the appopriate forums to get more help once you have some code to demonstrate.

    Michael Taylor
    http://www.michaeltaylorp3.net

    Wednesday, March 9, 2016 3:47 PM
    Moderator