Click here to Skip to main content
15,923,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this in c#
string jsonResultado = await Clases.AccesoDatos.JsonData("SELECT * FROM vistatransacciones for json path, ROOT('product.json')");

where method jsonData is:
  public static async Task<string> JsonData(string SQL)
            string json = "";
            using (SqlConnection con = new SqlConnection(cadenaConexion))
                SqlCommand cmd = new SqlCommand(SQL, con);
                await con.OpenAsync();
                SqlDataReader dr = await cmd.ExecuteReaderAsync();                
                if (dr.HasRows)
                    DataTable jsondt = dr.GetSchemaTable();                    
                    json= JsonConvert.SerializeObject(jsondt);
            return json;

In fact, after the if(dr.hasrows) i do not know what to do, i just want to read following result in my program:

But i do not know how to return the value

What I have tried:

codeproject paper, manuals, microsoft
Updated 2-Feb-23 5:27am

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