the code below is working perfectly but I would like to know a way to pull the column headings out too? I would like it inside my while loop if possible. Hopefully someone here can help.
Thanks, James.
namespace WorldViewNet.include
{
    public class ImageHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            object data = LoadAPI(context);
            string jsonData = JsonConvert.SerializeObject(data);
            context.Response.Write(jsonData);
        }
        public List<object[]> LoadAPI(HttpContext context)
        {
            List<object[]> list = new List<object[]>();
            SqlConnection sqlConnection1 = new SqlConnection(globalLibrary.NewConnectionString);
            SqlCommand cmd = new SqlCommand();
            SqlDataReader reader;
            string tablename = context.Request.QueryString["tablename"];
            string maybeID = context.Request.QueryString["ID"];
            cmd.CommandText = "SELECT * FROM " + tablename;
            if (maybeID != null)
            {
                cmd.CommandText += " WHERE " + tablename + "ID =" + maybeID;
            }
            cmd.CommandType = CommandType.Text;
            cmd.Connection = sqlConnection1;
            sqlConnection1.Open();
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                object[] row = new object[23];
                reader.GetValues(row);
                list.Add(row);
            }
            sqlConnection1.Close();
            return list;
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
 
    