Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
public string GetUser()
        {

            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbcon"].ConnectionString);
            SqlCommand sqcmd = new SqlCommand("sp_showUser", conn);
            sqcmd.CommandType = CommandType.StoredProcedure;
            string al = null;
            try
            {
                conn.Open();
                SqlDataReader sdr = sqcmd.ExecuteReader();
                DataSet ds = new DataSet();
                ds.Tables.Add("Users");
                StringWriter sw = new StringWriter();
                ds.WriteXml(sw, XmlWriteMode.IgnoreSchema);
                al = sw.ToString();
            }
            catch (Exception er)
            {
                Console.WriteLine("Exception : {0}", er.Message);
                Console.Read();
            }
            finally
            { conn.Close(); }

            return al;
}


What I have tried:

HttpClient client = new HttpClient();
            string response = client.GetAsync("http://localhost:61750/UserService.svc/GetUser").Result.ToString();
            //HttpContent strm = response.Content;
            //string data = strm.ReadAsStringAsync().ToString();
            DataSet dSUser = new DataSet();
            TextReader reader = new StringReader(response);
            dSUser.ReadXml(reader);
                GridView1.DataSource = dSUser;
                GridView1.DataBind();
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900