OdbcColumn.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. //
  2. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining
  5. // a copy of this software and associated documentation files (the
  6. // "Software"), to deal in the Software without restriction, including
  7. // without limitation the rights to use, copy, modify, merge, publish,
  8. // distribute, sublicense, and/or sell copies of the Software, and to
  9. // permit persons to whom the Software is furnished to do so, subject to
  10. // the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be
  13. // included in all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. //
  23. using System;
  24. namespace System.Data.Odbc
  25. {
  26. /// <summary>
  27. /// Summary description for OdbcColumn.
  28. /// </summary>
  29. internal class OdbcColumn
  30. {
  31. internal string ColumnName;
  32. internal OdbcType OdbcType;
  33. internal bool AllowDBNull;
  34. internal int MaxLength;
  35. internal int Digits;
  36. internal object Value;
  37. internal OdbcColumn(string Name, OdbcType Type)
  38. {
  39. this.ColumnName=Name;
  40. this.OdbcType=Type;
  41. AllowDBNull=false;
  42. MaxLength=0;
  43. Digits=0;
  44. Value=null;
  45. }
  46. internal Type DataType
  47. {
  48. get
  49. {
  50. switch (OdbcType)
  51. {
  52. case OdbcType.TinyInt:
  53. return typeof(System.Byte);
  54. case OdbcType.BigInt:
  55. return typeof(System.Int64);
  56. case OdbcType.Image:
  57. case OdbcType.VarBinary:
  58. case OdbcType.Binary:
  59. return typeof(byte[]);
  60. case OdbcType.Bit:
  61. return typeof(bool);
  62. case OdbcType.NChar:
  63. case OdbcType.Char:
  64. return typeof(char);
  65. case OdbcType.Time:
  66. case OdbcType.Timestamp:
  67. case OdbcType.DateTime:
  68. case OdbcType.Date:
  69. case OdbcType.SmallDateTime:
  70. return typeof(DateTime);
  71. case OdbcType.Decimal:
  72. return typeof(Decimal);
  73. case OdbcType.Numeric:
  74. case OdbcType.Double:
  75. return typeof(Double);
  76. case OdbcType.Int:
  77. return typeof(System.Int32);
  78. case OdbcType.Text:
  79. case OdbcType.NText:
  80. case OdbcType.NVarChar:
  81. case OdbcType.VarChar:
  82. return typeof(string);
  83. case OdbcType.Real:
  84. return typeof(float);
  85. case OdbcType.SmallInt:
  86. return typeof(System.Int16);
  87. case OdbcType.UniqueIdentifier:
  88. return typeof(Guid);
  89. }
  90. throw new InvalidCastException();
  91. }
  92. }
  93. internal bool IsDateType
  94. {
  95. get
  96. {
  97. switch (OdbcType)
  98. {
  99. case OdbcType.Time:
  100. case OdbcType.Timestamp:
  101. case OdbcType.DateTime:
  102. case OdbcType.Date:
  103. case OdbcType.SmallDateTime:
  104. return true;
  105. default:
  106. return false;
  107. }
  108. }
  109. }
  110. internal bool IsStringType
  111. {
  112. get
  113. {
  114. switch (OdbcType)
  115. {
  116. case OdbcType.Text:
  117. case OdbcType.NText:
  118. case OdbcType.NVarChar:
  119. case OdbcType.VarChar:
  120. return true;
  121. default:
  122. return false;
  123. }
  124. }
  125. }
  126. }
  127. }