Exemple #1
0
        public static System.Data.DataTable CreateDataTable(string objectName, sforce.DescribeSObjectResult dsr)
        {
            System.Data.DataTable dt = new System.Data.DataTable(objectName);
            //build column list
            string selectList = "";

            for (int i = 0; i < dsr.fields.Length; i++)
            {
                System.Data.DataColumn dc = new System.Data.DataColumn(dsr.fields[i].name, GetSystemType(dsr.fields[i].type));
                dc.ReadOnly    = !dsr.fields[i].updateable;
                dc.AllowDBNull = dsr.fields[i].nillable;
                if (dsr.fields[i].length > 0)
                {
                    dc.MaxLength = dsr.fields[i].length;
                }
                if (dsr.fields[i].label != null)
                {
                    dc.Caption = dsr.fields[i].label;
                }
                else
                {
                    dc.Caption = dsr.fields[i].name;
                }
                dt.Columns.Add(dc);
                selectList += dsr.fields[i].name + ", ";
            }
            return(dt);
        }
Exemple #2
0
        public static string CreateSelectList(sforce.DescribeSObjectResult dsr)
        {
            string selectList = "";

            for (int i = 0; i < dsr.fields.Length; i++)
            {
                selectList += dsr.fields[i].name + ", ";
            }
            selectList = selectList.Substring(0, selectList.Length - 2);
            return(selectList);
        }