OdbcColumn.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using System;
  2. namespace System.Data.Odbc
  3. {
  4. /// <summary>
  5. /// Summary description for OdbcColumn.
  6. /// </summary>
  7. internal class OdbcColumn
  8. {
  9. internal string ColumnName;
  10. internal OdbcType OdbcType;
  11. internal bool AllowDBNull;
  12. internal int MaxLength;
  13. internal int Digits;
  14. internal object Value;
  15. internal OdbcColumn(string Name, OdbcType Type)
  16. {
  17. this.ColumnName=Name;
  18. this.OdbcType=Type;
  19. AllowDBNull=false;
  20. MaxLength=0;
  21. Digits=0;
  22. Value=null;
  23. }
  24. internal Type DataType
  25. {
  26. get
  27. {
  28. switch (OdbcType)
  29. {
  30. case OdbcType.TinyInt:
  31. return typeof(System.Byte);
  32. case OdbcType.BigInt:
  33. return typeof(System.Int64);
  34. case OdbcType.Image:
  35. case OdbcType.VarBinary:
  36. case OdbcType.Binary:
  37. return typeof(byte[]);
  38. case OdbcType.Bit:
  39. return typeof(bool);
  40. case OdbcType.NChar:
  41. case OdbcType.Char:
  42. return typeof(char);
  43. case OdbcType.Time:
  44. case OdbcType.Timestamp:
  45. case OdbcType.DateTime:
  46. case OdbcType.Date:
  47. case OdbcType.SmallDateTime:
  48. return typeof(DateTime);
  49. case OdbcType.Decimal:
  50. return typeof(Decimal);
  51. case OdbcType.Numeric:
  52. case OdbcType.Double:
  53. return typeof(Double);
  54. case OdbcType.Int:
  55. return typeof(System.Int32);
  56. case OdbcType.Text:
  57. case OdbcType.NText:
  58. case OdbcType.NVarChar:
  59. case OdbcType.VarChar:
  60. return typeof(string);
  61. case OdbcType.Real:
  62. return typeof(float);
  63. case OdbcType.SmallInt:
  64. return typeof(System.Int16);
  65. case OdbcType.UniqueIdentifier:
  66. return typeof(Guid);
  67. }
  68. throw new InvalidCastException();
  69. }
  70. }
  71. internal bool IsDateType
  72. {
  73. get
  74. {
  75. switch (OdbcType)
  76. {
  77. case OdbcType.Time:
  78. case OdbcType.Timestamp:
  79. case OdbcType.DateTime:
  80. case OdbcType.Date:
  81. case OdbcType.SmallDateTime:
  82. return true;
  83. default:
  84. return false;
  85. }
  86. }
  87. }
  88. internal bool IsStringType
  89. {
  90. get
  91. {
  92. switch (OdbcType)
  93. {
  94. case OdbcType.Text:
  95. case OdbcType.NText:
  96. case OdbcType.NVarChar:
  97. case OdbcType.VarChar:
  98. return true;
  99. default:
  100. return false;
  101. }
  102. }
  103. }
  104. }
  105. }