views:

393

answers:

3

Hi,

I am working on a wcf application where i want to access some columns from a table (prefebly via stored procedure) through wcf and pass it to client. I have searched a lot on the google but unable to find a good example of it. Can some one help me please.

Thanks in advance

A: 

erm write a datacontract serializable class and have a method on it to populate itself using a connection object?

PeanutPower
i have tried that and it works when i execute a procedure for inserting, updating or deleting in database but when i try to get records in multiple columns i am not getting it. I need a datatable with records and return it to client. I have done it so many times in web forms but not in wcf services. it will be great if u can provide me some sample code as i m new in wcf
pankaj
A: 

Any of the DB APIs will allow you access to SQL. Recently, I've used mostly the Entity Frameworks with my WCF services. All was fine and dandy, once you get the connection string(s) worked out to each of your databases.

kenny
thanks for replying, i have no problem in accessing sql server but when i try to fetch multible rows from a table using stored procedure i am not able to do it.
pankaj
What I did was use the Entities design surface and Server Explorer to drag over the stored procs I was interested in and then they were in the datacontext.StoredProc(...).
kenny
A: 

Make sure your types are serializable. Based on your comment to PeanutPower's answer it looks like you'll need to make sure TBL_CONTENTTEMPLATE is serializable. Also verify you have your service contract defined on the client side to accept a collection type of System.Collections.Generic.List, the default is System.Array and I've run into problems in the past when the client contract was misconfigured in this way.

Jacob Ewald