read Json type data from SQL and send it to a text file

0

Hello friends, start working on a C # code that you have to do only, read a query in my database (that query converts my table to Json type formats) then the result of the query has to be sent to a Json type file. I have never worked with Json type formats and I do not know how to do these actions, to see if someone can give me a hand with this and explain how I can do these operations with this format.

string query="dataJson";
        try
        {
            con.Open();
            SqlCommand cmd = new SqlCommand(query, con);
            cmd.CommandType = CommandType.StoredProcedure;


            using (JsonReader xrdr = cmd.ExecuteXmlReader())
            {
                using (JsonWriter writer = JsonWriter.Create(File.OpenWrite(@"F:\Programador Ano\Semestre_2\C#\Project\dataXml.xml")))
                {
                    writer.WriteNode(xrdr, true);
                }
            }

            MessageBox.Show(@"F:\Programador Ano\Semestre_2\C#\Project  ", " JSON file created ");
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
    
asked by Julio Mizrahi 27.06.2018 в 09:07
source

0 answers