You must Sign In to post a response.
  • Category: Webservices

    How to return Dataset in webservice

    [HttpGet]

    public DataSet GetFloorDetails()


    {

    localhost.FloorDetails test = new localhost.FloorDetails();
    test.Build_ID=1;
    test.FloorId=2;
    return test // Error


    }


    i facing error for return test.

    any one help.
  • #769244
    Hi
    you can try this code


    [WebMethod]
    public DataSet GetData()
    {
    // First Create a New Connection
    SqlConnection sqlConnection1 = new SqlConnection();
    // Now Pass a Connection String To the Connection
    sqlConnection1.ConnectionString = "data source=PC-NAME;Initial Catalog=DB-NAME;Integrated Security=True;user id=USERNAME;password=PWD";
    // Now the Select statement you want to run
    string select ="select * from products";
    SqlDataAdapter da = new SqlDataAdapter(select,sqlConnection1);
    DataSet ds = new DataSet();
    // Fill The DataSet With the Contents of the Stock Table
    da.Fill(ds , "stock");
    return(ds);
    }

    Name : Dotnet Developer-2015
    Email Id : kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.


  • Sign In to post your comments