call select stored procedure using WCF Service? display data in xml format [Resolved]

Posted by Mandlaa under WCF on 9/30/2014 | Points: 10 | Views : 1245 | Status : [Member] | Replies : 3
How to call select stored procedure using WCF Service?

The data display in xml format

This is my code

Interface:

[WebInvoke(ResponseFormat = WebMessageFormat.Xml)]
[OperationContract]
DataSet Loadstatus();

Implementation:

public DataSet Loadstatus1()
{
SqlConnection con = new SqlConnection(@"Data Source=ASHDEVBTS-1;Initial Catalog=Sampath;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Clear();
cmd.CommandText = "SelectLoad";
//cmd.Parameters.AddWithValue("@LoadId", LoadId);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "ShipperLoadStatus");
return ds;
}

Stored procedure:

create procedure SelectLoad
as
begin
select LoadId,TrailerNum,DriverName,VehicleNumber from ShipperLoadStatus
end


I am not getting any error

But not getting data from database

plz what is the mistake?




Responses

Posted by: Mandlaa on: 9/30/2014 [Member] Starter | Points: 25

Up
0
Down

Resolved
I got the solution

Mandlaa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naveenhcl on: 10/1/2014 [Member] Starter | Points: 25

Up
0
Down
Hi,

Happy to here to resolve the issue by your own, keep up with the Good work.

All the Best..

Mandlaa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mandlaa on: 10/1/2014 [Member] Starter | Points: 25

Up
0
Down
Thank,I have one more doubt
I did the wcf to display data from database using stored procedure,

I am getting data also

I am getting output like this,

OUTPUT
http://postimg.org/image/dyvck5ojn/

The above output getting schema definition,I don't want that schema definition.

I want to the below output,

<?xml version="1.0" encoding="UTF-8"?>
<TranscomXML xmlns="ShipperLoadStatus.xsd" created="201405281117" batchref="LS-56273-260449.xml">

<ShipperLoadStatus diffgr:id="ShipperLoadStatus1" msdata:rowOrder="0">

<LoadId>1</LoadId>

<TrailerNum>12345</TrailerNum>

<DriverName>Sampath</DriverName>

<VehicleNumber>A1234</VehicleNumber>

</ShipperLoadStatus>

</TranscomXML>


How can i get the above out put

Can you please help me

Mandlaa, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response