Posts

Showing posts from October, 2017

Send List of data to web api using httppost from c#

      public Result SaleListSend(string _baseUrl, Token token, List<SaleViewModel> list)         {             var client = new HttpClient();             client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);             var serializedDate = JsonConvert.SerializeObject(list);             var content = new StringContent(serializedDate, Encoding.UTF8, "application/json");             using (var response = client.PostAsync(_baseUrl + "api/Sale/PostSales", content))             {                 if (response.Result.IsSuccessStatusCode)                 {                     string st...

GetToken From c# codebehind using HttpClient

        public Token GetToken(string _baseUrl, string userName,string password)         {             var client = new HttpClient();             var authorizationHeader = Convert.ToBase64String(Encoding.UTF8.GetBytes("xyz:secretKey"));             client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authorizationHeader);             var form = new Dictionary<string, string>                {                    {"grant_type", "password"},                    {"username", userName},                    {"password",password},                };     ...

Multiple rows to one comma-separated value [duplicate]

This question already has an answer here: Concatenate many rows into a single text string?   38 answers How to create a SQL Server function to “join” multiple rows from a subquery into a single delimited field? [duplicate]   13 answers I want to create a table valued function in SQL Server, which I want to return data in comma separated values. For example table:  tbl ID | Value ---+------- 1 | 100 1 | 200 1 | 300 1 | 400 Now when I execute the query using the function  Func1(value) SELECT Func1 ( Value ) FROM tbl WHERE ID = 1 Output that I want is:  100,200,300,400 up vote down vote accepted Test Data DECLARE @ Table1 TABLE ( ID INT , Value INT ) INSERT INTO @ Table1 VALUES ( 1 , 100 ),( 1 , 200 ),( 1 , 300 ),( 1 , 400 ) Query SELECT ID , STUFF (( SELECT ', ' + CAST ( Value AS VARCHAR ( 10 )) [ text ()] FROM @ Table1 WHERE ID = t . ID FOR XML PA...