title: SQL table to JSON file
body: <p>How can I make this piece of code i have to generate a JSON file for me?</p>
  
  <p>Right now I read the values into a string, but I want it to generate the file automatically.</p>
  
  <pre><code> using (SqlDataReader reader = cmd.ExecuteReader())
   {
        while (reader.Read())
        {
              userinfo info = new userinfo();
  
              info.userid = reader.GetInt32(0);
              info.username = reader.GetValue(1).ToString();
              info.password = reader.GetValue(2).ToString();
              info.firstname = reader.GetValue(3).ToString();
              info.lastname = reader.GetValue(4).ToString();
              info.dob = reader.GetValue(5).ToString();
              info.dateregistered = reader.GetValue(6).ToString();
  
              JavaScriptSerializer jss = new JavaScriptSerializer();
              jsonString = jss.Serialize(info);
             //string json = JsonConvert.SerializeObject(info);
        }
   }
  </code></pre>