本文整理汇总了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);
}
}