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; }
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();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)