troubleshooting Question

Take output from SQL Server stored proc and convert output of multiple line resultset into 1 JSON packet in C#

Avatar of Bill Park
Bill ParkFlag for United States of America asked on
* ADOSQLC#Microsoft SQL ServerJSON
5 Comments1 Solution17 ViewsLast Modified:
I have a stored procedure that produces output that looks (in SSMS) like this:
Device               Loc   CaptureTime
0000000001D0   9   22:18:05
000000000402   3   22:18:05
00000000016C   7   22:18:05
00000000013D   7   22:18:05

There could be several hundred rows like this.
I need to create a single JSON package  of all of the records in the  SQL resultset in C#.
I know how to connect to the database and execute the stored procedure.
Using the following I get all of the contents of just first column (I think):
                String strResultSet = rdr.GetString(0);
                Console.WriteLine("{0}", strResultSet);
I think I need to get DataReader to return all of the columns of each record. I don't know how.
Then, is there a way within DataReader for all records to be appended to strResultSet or will I need to concatenate each new record explicitly?

Please consider me as someone who has not done anything in C# until very recently.

Thank you.

Why fewer and fatter packets? Something to do with how Azure charges for IoTHub messages.

Yes, I'm very new to this.
Andrei Fomitchev

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros