15,898,134 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by aakar (Top 12 by date)
aakar
16-Jul-21 10:43am
View
No, presently the code is single threaded, any leads would be much appreciated!
aakar
16-Jul-21 5:10am
View
Hi, my code which was working fine has run into issues. worse part is that it runs most of the times but at times I am getting a 401 "Unauthorized" error at the response step. Can you pls help?
aakar
11-Feb-21 21:46pm
View
Hi, I have split the 2 strings into 2 table variables. Now how do I loop through these and add the params to the SP one by one?
The 2 variables are as below :
@a
-----
[Deptname]
[Location]
[Column1]
[Column2]
[Column3]
@b
-------
testval1,
testval2,
30,
50,
60
and the code that I am using is :
declare @a varchar(100)
set @a = '[Deptname],[Location],[Column1],[Column2],[Column3]'
select
a.value('.', 'varchar(max)')
from
(select cast('<m>' + REPLACE(@a, ',', '<m>') + '' AS XML) as col) as A
CROSS APPLY A.col.nodes ('/M') AS Split(a)
declare @b varchar(100)
set @b = 'testval1','testval2','30','50','60'
select
b.value('.', 'varchar(max)')
from
(select cast('<m>' + REPLACE(@b, ',', '<m>') + '' AS XML) as col) as B
CROSS APPLY B.col.nodes ('/M') AS Split(B)
Can you please help?
aakar
9-Feb-17 8:41am
View
Hi Sonymon,
Thanks for the solution. It works fine, however I require 2 levels of Totals
i.e. Region Asset is Asia ex-Japan and Class is Bonds.
Therefore I would require both the Class Total as well as the Region Asset Total.
Your solution helped me get the Class Total across my dataset. How do I get the Region Asset Total as well?
aakar
6-Feb-17 0:54am
View
Region Asset Class Dividends PnL Bonus
Asia ex-Japan Bonds 10000 10000 10000
Asia ex-Japan Bonds 20000 20000 20000
Asia ex-Japan Bonds 30000 30000 30000
Asia ex-Japan Bonds 40000 40000 40000
Bonds Total 100000 100000 100000
Asia ex-Japan Total 153200 153200 153200
The o/p is required in the above format for each Region (i.e the outer group total) and the Asset Class (i.e the inner group total)
Hope I am clear...
aakar
5-Feb-17 11:30am
View
yes, the solution you provide works like a charm. Just 1 thing though.
I am currently getting tow resultsets :
var _result1 = from r1 in DT.AsEnumerable()
group r1 by new
{
RegionAsset = r1.Field<string>("Region Asset"),
Class = r1.Field<string>("Class"),
} into g
select new
{
RegionAsset = g.Key.RegionAsset,
Class = g.Key.Class,
TotalDividends = g.Sum(x => x.Field<int>("Dividends")),
TotalPnL = g.Sum(x => x.Field<int>("PnL")),
TotalBonus = g.Sum(x => x.Field<int>("Bonus"))
};
var _result2 = from r1 in DT.AsEnumerable()
group r1 by new
{
RegionAsset = r1.Field<string>("Region Asset")
} into g
select new
{
RegionAsset = g.Key.RegionAsset,
TotalDividends = g.Sum(x => x.Field<int>("Dividends")),
TotalPnL = g.Sum(x => x.Field<int>("PnL")),
TotalBonus = g.Sum(x => x.Field<int>("Bonus"))
};
Now, how do I iterate through the above two vars (i.e. _result1 and _result2)
and get the o/p in the desired format.
The second var i.e. _result2 has the information grouped at a higher level whereas the first var i.e. _result1 has the information grouped one level down.
I would require the outer group total first in excel then followed by the inner group total. Any ideas?
aakar
26-Jan-17 14:36pm
View
Hi Sonymon,
Thanks for the solution.
But this is a legacy application that was built in VS 2008. We cannot use LINQ here. Is there any way we can accomplish this using C#2.0?
aakar
23-Aug-16 4:14am
View
Thanks all for your suggestions! However, the report that I need should look like :
Region Country Earnings
Americas USA 50000
Americas Mexico 20000
Americas Canada 10000
Asia-Pac China 70000
Asia-Pac Japan 40000
aakar
18-Dec-14 6:56am
View
Thanks Damith! the solution works fine for the columns from the DB.
I am using SQL Server as the DB. sorry for not having mentioned it in my post earlier!
However, if I use the above for a column that I am adding to my Dataset at runtime, it still tells me "Specified Cast is not Valid".
aakar
18-Dec-14 3:42am
View
The DB datatype is float
aakar
18-Dec-14 3:25am
View
I tried the two solutions with the field extension method, but I am getting a "Specified Cast is not Valid" error message.
aakar
12-Feb-14 1:36am
View
yes col4 is required to be selected as the fourth column
Show More