hello

Monday, 22 October 2012

WebService Example

 [WebMethod]
    public DataSet GetUserDetails()
    {
        SqlConnection con = new SqlConnection("Data Source=COM-827A9D94467;Initial Catalog=test;Integrated Security=True");
        con.Open();
        SqlCommand cmd = new SqlCommand("select * from TabLogindetails", con);
        cmd.ExecuteNonQuery();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        // Create an instance of DataSet.
        DataSet ds = new DataSet();
        da.Fill(ds);
        con.Close();
        // Return the DataSet as an XmlElement.
        return ds;
    }

//aspx
localhost.WebService objUserDetails = new localhost.WebService();
            dsresult = new DataSet();
            dsresult = objUserDetails.GetUserDetails();
            gvUserDetails.DataSource = dsresult;
            gvUserDetails.DataBind();

No comments:

Post a Comment