Link to home
Start Free TrialLog in
Avatar of VPry
VPry

asked on

Access SQL Server with WCF example

Hello everybody!

I am running simple WPF application with MVVM. Could anybody provide me with an example how to read SQL Server data and display it in my View? Sort SQL Server/WCF “Hello World”.

Thank you!
Avatar of SameerJagdale
SameerJagdale
Flag of United States of America image

your question is very unclear, what you want to do? are you looking for WCF service to access SQL data?
Avatar of VPry
VPry

ASKER

I am new to WCF/WPF. And I am looking for WCF service to access SQL data :)
In WCF you can get data in same manners as you get in normal way, please follow the link for more details:
http://www.developerfusion.com/article/4278/using-adonet-with-sql-server/4/
WCF can very well work with your SQL server, it doesn't need anything specific as such, however, you should also consider the purpose of WCF, WCF is targetted as a step towards SOA so your service should not return anything specific to SQL, the ideal thing is to return entities, you can very well make use of LINQ with WCF to make it more useful, have a look at the codeproject sample to get an idea of how you can do that - http://www.codeproject.com/KB/WCF/LinqWcfService.aspx
Avatar of VPry

ASKER

Hi everybody! Thank you for all your responses and usefull links!

I think I am on a wrong path in terms of architecture for my project.
My WPF application draws polygons based on point coordinates. Points are stored in SQL Server database. I need to access this database and return data to my app. I thought that I have to use WCF to do this job. I guess I don’t have to, right?
In fact I think this will only add another level of complexity to my app.

Could anybody explain me should I use WCF or not for my scenario?
What are advantages/disadvantages in this approach?
Or should I just use ADO.NET with SQL Server like IJZ recommended?  Thank you guys! :)
ASKER CERTIFIED SOLUTION
Avatar of Imran Javed Zia
Imran Javed Zia
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of VPry

ASKER

Hi IJZ,
I still didn't find a good simple example how to use WCF between my app and SQL Server db. I just want to read some data from table and display it in window of WPF test application. Could you help me with this? Thank you!
Avatar of VPry

ASKER

It's not a solution but a direction to follow. Thank you!