Oct 11th, 2009, 09:24 PM
connect to database
ok so I am a bit confused and looking for some clarification. Basically what i am trying to do is build a silverlight application that will use a wcf service to get data from. So for example in my application I can have a dropdown list of states that gets populated from a database. So my understanding is that first I create the silverlight application. Then I create the wcf service with a method in there that will give me a list(or whatever data I need). Once I have done that I add a service reference in my silverlight app and bind that to the dropdown list(or wherever I need it).
Now I created a simple wcf service that just returned "the number you entered was (number here)" whatever number they had entered into a text box before they hit submit. Which worked fine. However, the part that I am confused about is the whole database portion. From the way I understand it I make the connection to the database in the wcf service and get the data there and just return whatever is needed. Please let me know if I am wrong. But, I cannot seem to figure out how to make the database accessible from the wcf service. I created a simple database in the wcf service solution but was unsure how to actually make the connection. Any help is appreciated.
If I helped you please rate
Oct 12th, 2009, 03:54 AM
Re: connect to database
Well it sounds like you have got the hang of the WCF and the Silverlight part of things so I dont think this thread really belongs here in the WCF forum You read data from a database in WCF in the exact same way as you read data from a database in any other kind of project.
Basically you need to give the WCF service some way of knowing where the database is, then when your WCF service receives a request you can use the ADO.NET classes to read data from the database and return a list or whatever you want to the caller of the WCF service.
So the only thing you need to learn by the sounds of things is how to read data from a database and there are loads of examples of how to do that on these forums alone
Click Here to Expand Forum to Full Width