當前位置: 首頁>>代碼示例>>C#>>正文


C# DataColumn.SetByteLength方法代碼示例

本文整理匯總了C#中System.Data.DataColumn.SetByteLength方法的典型用法代碼示例。如果您正苦於以下問題:C# DataColumn.SetByteLength方法的具體用法?C# DataColumn.SetByteLength怎麽用?C# DataColumn.SetByteLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Data.DataColumn的用法示例。


在下文中一共展示了DataColumn.SetByteLength方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FillSchemaFromFieldDescriptorList

        private void FillSchemaFromFieldDescriptorList(DataTable table)
        {
            foreach (FieldDescriptor fd in this.FieldDescriptors)
            {
                DataColumn col = new DataColumn(fd.FieldName);
                //DbaseIIIDataColumn col = new DbaseIIIDataColumn(fd.FieldName);
                col.DataType = typeof(object);

                //http://www.clicketyclick.dk/databases/xbase/format/data_types.html
                switch (fd.FieldType)
                {
                    case 'C': //string < 254 chars
                        col.DataType = typeof(string);
                        //Below ensures we can fit an int's string representation since the original
                        //length is specified in bytes for the char[]. Go larger if specified (like DES in HEADER.DBF).
                        col.MaxLength = fd.FieldLength < 11 ? 11 : fd.FieldLength;
                        col.SetByteLength(fd.FieldLength);
                        break;
                    case 'N': //int64 (up to 18 chars according to dBase spec)
                        col.DataType = typeof(long);
                        col.SetByteLength(fd.FieldLength);
                        break;
                    case 'L': //nullable bool, byte
                        throw new NotImplementedException("Encountered /'L/' for nullable bool!");
                        break;
                    case 'D': //YYYYMMDD
                        throw new NotImplementedException("Encountered /'D/' for YYYYMMDD!");
                        break;
                    case '@': //long1 = days since 1-Jan-4713 BC, long2 = hrs * 3600000 + min * 60000 + sec * 1000
                        throw new NotImplementedException("Encountered /'@/' for time!");
                        break;
                    case 'O': //double (8 bytes)
                        throw new NotImplementedException("Encountered /'O/' for double!");
                        break;
                    case '+': //auto-increment (long)
                        throw new NotImplementedException("Encountered /'+/' for auto-increment!");
                        break;
                }

                table.Columns.Add(col);
            }
        }
開發者ID:sraboy,項目名稱:skaa_editor,代碼行數:42,代碼來源:DbfFile.cs


注:本文中的System.Data.DataColumn.SetByteLength方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。