SqlParameter.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. //
  2. // System.Data.SqlClient.SqlParameter.cs
  3. //
  4. // Author:
  5. // Rodrigo Moya ([email protected])
  6. // Daniel Morgan ([email protected])
  7. // Tim Coleman ([email protected])
  8. // Diego Caravana ([email protected])
  9. //
  10. // (C) Ximian, Inc. 2002
  11. // Copyright (C) Tim Coleman, 2002
  12. //
  13. //
  14. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  15. //
  16. // Permission is hereby granted, free of charge, to any person obtaining
  17. // a copy of this software and associated documentation files (the
  18. // "Software"), to deal in the Software without restriction, including
  19. // without limitation the rights to use, copy, modify, merge, publish,
  20. // distribute, sublicense, and/or sell copies of the Software, and to
  21. // permit persons to whom the Software is furnished to do so, subject to
  22. // the following conditions:
  23. //
  24. // The above copyright notice and this permission notice shall be
  25. // included in all copies or substantial portions of the Software.
  26. //
  27. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  28. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  29. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  30. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  31. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  32. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  33. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  34. //
  35. using Mono.Data.Tds;
  36. using Mono.Data.Tds.Protocol;
  37. using System;
  38. using System.ComponentModel;
  39. using System.Data;
  40. using System.Data.Common;
  41. #if NET_2_0
  42. using System.Data.ProviderBase;
  43. #endif // NET_2_0
  44. using System.Runtime.InteropServices;
  45. using System.Text;
  46. namespace System.Data.SqlClient {
  47. [TypeConverterAttribute (typeof (SqlParameterConverter))]
  48. #if NET_2_0
  49. public sealed class SqlParameter : DbParameterBase, IDbDataParameter, IDataParameter, ICloneable
  50. #else
  51. public sealed class SqlParameter : MarshalByRefObject, IDbDataParameter, IDataParameter, ICloneable
  52. #endif // NET_2_0
  53. {
  54. #region Fields
  55. TdsMetaParameter metaParameter;
  56. SqlParameterCollection container = null;
  57. DbType dbType;
  58. ParameterDirection direction = ParameterDirection.Input;
  59. bool isNullable;
  60. bool isSizeSet = false;
  61. bool isTypeSet = false;
  62. int offset;
  63. SqlDbType sqlDbType;
  64. string sourceColumn;
  65. DataRowVersion sourceVersion;
  66. #endregion // Fields
  67. #region Constructors
  68. public SqlParameter ()
  69. : this (String.Empty, SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, String.Empty, DataRowVersion.Current, null)
  70. {
  71. }
  72. public SqlParameter (string parameterName, object value)
  73. {
  74. metaParameter = new TdsMetaParameter (parameterName, value);
  75. this.sourceVersion = DataRowVersion.Current;
  76. InferSqlType (value);
  77. }
  78. public SqlParameter (string parameterName, SqlDbType dbType)
  79. : this (parameterName, dbType, 0, ParameterDirection.Input, false, 0, 0, String.Empty, DataRowVersion.Current, null)
  80. {
  81. }
  82. public SqlParameter (string parameterName, SqlDbType dbType, int size)
  83. : this (parameterName, dbType, size, ParameterDirection.Input, false, 0, 0, String.Empty, DataRowVersion.Current, null)
  84. {
  85. }
  86. public SqlParameter (string parameterName, SqlDbType dbType, int size, string sourceColumn)
  87. : this (parameterName, dbType, size, ParameterDirection.Input, false, 0, 0, sourceColumn, DataRowVersion.Current, null)
  88. {
  89. }
  90. [EditorBrowsable (EditorBrowsableState.Advanced)]
  91. public SqlParameter (string parameterName, SqlDbType dbType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)
  92. {
  93. metaParameter = new TdsMetaParameter (parameterName, size, isNullable, precision, scale, value);
  94. SqlDbType = dbType;
  95. Direction = direction;
  96. SourceColumn = sourceColumn;
  97. SourceVersion = sourceVersion;
  98. }
  99. // This constructor is used internally to construct a
  100. // SqlParameter. The value array comes from sp_procedure_params_rowset.
  101. // This is in SqlCommand.DeriveParameters.
  102. internal SqlParameter (object[] dbValues)
  103. : this (dbValues [3].ToString (), String.Empty)
  104. {
  105. Precision = 0;
  106. Scale = 0;
  107. Direction = ParameterDirection.Input;
  108. ParameterName = (string) dbValues[3];
  109. switch ((short) dbValues[5]) {
  110. case 1:
  111. Direction = ParameterDirection.Input;
  112. break;
  113. case 2:
  114. Direction = ParameterDirection.Output;
  115. break;
  116. case 3:
  117. Direction = ParameterDirection.InputOutput;
  118. break;
  119. case 4:
  120. Direction = ParameterDirection.ReturnValue;
  121. break;
  122. default:
  123. Direction = ParameterDirection.Input;
  124. break;
  125. }
  126. IsNullable = (dbValues [8] != null &&
  127. dbValues [8] != DBNull.Value) ? (bool) dbValues [8] : false;
  128. if (dbValues [12] != null && dbValues [12] != DBNull.Value)
  129. Precision = (byte) ((short) dbValues [12]);
  130. if (dbValues [13] != null && dbValues [13] != DBNull.Value)
  131. Scale = (byte) ( (short) dbValues [13]);
  132. SetDbTypeName ((string) dbValues [16]);
  133. }
  134. #endregion // Constructors
  135. #region Properties
  136. // Used to ensure that only one collection can contain this
  137. // parameter
  138. internal SqlParameterCollection Container {
  139. get { return container; }
  140. set { container = value; }
  141. }
  142. [Browsable (false)]
  143. [DataCategory ("Data")]
  144. [DataSysDescription ("The parameter generic type.")]
  145. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  146. [RefreshProperties (RefreshProperties.All)]
  147. public
  148. #if NET_2_0
  149. override
  150. #endif // NET_2_0
  151. DbType DbType {
  152. get { return dbType; }
  153. set {
  154. SetDbType (value);
  155. isTypeSet = true;
  156. }
  157. }
  158. [DataCategory ("Data")]
  159. [DataSysDescription ("Input, output, or bidirectional parameter.")]
  160. [DefaultValue (ParameterDirection.Input)]
  161. public
  162. #if NET_2_0
  163. override
  164. #endif // NET_2_0
  165. ParameterDirection Direction {
  166. get { return direction; }
  167. set {
  168. direction = value;
  169. switch( direction ) {
  170. case ParameterDirection.Output:
  171. MetaParameter.Direction = TdsParameterDirection.Output;
  172. break;
  173. case ParameterDirection.InputOutput:
  174. MetaParameter.Direction = TdsParameterDirection.InputOutput;
  175. break;
  176. case ParameterDirection.ReturnValue:
  177. MetaParameter.Direction = TdsParameterDirection.ReturnValue;
  178. break;
  179. }
  180. }
  181. }
  182. internal TdsMetaParameter MetaParameter {
  183. get { return metaParameter; }
  184. }
  185. string IDataParameter.ParameterName {
  186. get { return metaParameter.ParameterName; }
  187. set { metaParameter.ParameterName = value; }
  188. }
  189. [Browsable (false)]
  190. [DataSysDescription ("a design-time property used for strongly typed code-generation.")]
  191. [DefaultValue (false)]
  192. [DesignOnly (true)]
  193. [EditorBrowsable (EditorBrowsableState.Advanced)]
  194. public
  195. #if NET_2_0
  196. override
  197. #endif // NET_2_0
  198. bool IsNullable {
  199. get { return metaParameter.IsNullable; }
  200. set { metaParameter.IsNullable = value; }
  201. }
  202. [Browsable (false)]
  203. [DataCategory ("Data")]
  204. [DataSysDescription ("Offset in variable length data types.")]
  205. [DefaultValue (0)]
  206. public
  207. #if NET_2_0
  208. override
  209. #endif // NET_2_0
  210. int Offset {
  211. get { return offset; }
  212. set { offset = value; }
  213. }
  214. [DataSysDescription ("Name of the parameter, like '@p1'")]
  215. [DefaultValue ("")]
  216. public
  217. #if NET_2_0
  218. override
  219. #endif // NET_2_0
  220. string ParameterName {
  221. get { return metaParameter.ParameterName; }
  222. set { metaParameter.ParameterName = value; }
  223. }
  224. [DataCategory ("Data")]
  225. [DataSysDescription ("For decimal, numeric, varnumeric DBTypes.")]
  226. [DefaultValue (0)]
  227. public
  228. #if NET_2_0
  229. override
  230. #endif // NET_2_0
  231. byte Precision {
  232. get { return metaParameter.Precision; }
  233. set { metaParameter.Precision = value; }
  234. }
  235. [DataCategory ("Data")]
  236. [DataSysDescription ("For decimal, numeric, varnumeric DBTypes.")]
  237. [DefaultValue (0)]
  238. public
  239. #if NET_2_0
  240. override
  241. #endif // NET_2_0
  242. byte Scale {
  243. get { return metaParameter.Scale; }
  244. set { metaParameter.Scale = value; }
  245. }
  246. [DataCategory ("Data")]
  247. [DataSysDescription ("Size of variable length datatypes (strings & arrays).")]
  248. [DefaultValue (0)]
  249. public
  250. #if NET_2_0
  251. override
  252. #endif // NET_2_0
  253. int Size {
  254. get { return metaParameter.Size; }
  255. set { metaParameter.Size = value; }
  256. }
  257. [DataCategory ("Data")]
  258. [DataSysDescription ("When used by a DataAdapter.Update, the source column name that is used to find the DataSetColumn name in the ColumnMappings. This is to copy a value between the parameter and a datarow.")]
  259. [DefaultValue ("")]
  260. public
  261. #if NET_2_0
  262. override
  263. #endif // NET_2_0
  264. string SourceColumn {
  265. get { return sourceColumn; }
  266. set { sourceColumn = value; }
  267. }
  268. [DataCategory ("Data")]
  269. [DataSysDescription ("When used by a DataAdapter.Update (UpdateCommand only), the version of the DataRow value that is used to update the data source.")]
  270. [DefaultValue (DataRowVersion.Current)]
  271. public
  272. #if NET_2_0
  273. override
  274. #endif // NET_2_0
  275. DataRowVersion SourceVersion {
  276. get { return sourceVersion; }
  277. set { sourceVersion = value; }
  278. }
  279. [DataCategory ("Data")]
  280. [DataSysDescription ("The parameter native type.")]
  281. [DefaultValue (SqlDbType.NVarChar)]
  282. [RefreshProperties (RefreshProperties.All)]
  283. public SqlDbType SqlDbType {
  284. get { return sqlDbType; }
  285. set {
  286. SetSqlDbType (value);
  287. isTypeSet = true;
  288. }
  289. }
  290. [DataCategory ("Data")]
  291. [DataSysDescription ("Value of the parameter.")]
  292. [DefaultValue (null)]
  293. [TypeConverterAttribute (typeof (StringConverter))]
  294. public
  295. #if NET_2_0
  296. override
  297. #endif // NET_2_0
  298. object Value {
  299. get { return metaParameter.Value; }
  300. set {
  301. if (!isTypeSet)
  302. InferSqlType (value);
  303. metaParameter.Value = value;
  304. }
  305. }
  306. #endregion // Properties
  307. #region Methods
  308. object ICloneable.Clone ()
  309. {
  310. return new SqlParameter (ParameterName, SqlDbType, Size, Direction, IsNullable, Precision, Scale, SourceColumn, SourceVersion, Value);
  311. }
  312. // If the value is set without the DbType/SqlDbType being set, then we
  313. // infer type information.
  314. private void InferSqlType (object value)
  315. {
  316. Type type = value.GetType ();
  317. string exception = String.Format ("The parameter data type of {0} is invalid.", type.Name);
  318. switch (type.FullName) {
  319. case "System.Int64":
  320. SetSqlDbType (SqlDbType.BigInt);
  321. break;
  322. case "System.Boolean":
  323. SetSqlDbType (SqlDbType.Bit);
  324. break;
  325. case "System.String":
  326. SetSqlDbType (SqlDbType.NVarChar);
  327. break;
  328. case "System.DateTime":
  329. SetSqlDbType (SqlDbType.DateTime);
  330. break;
  331. case "System.Decimal":
  332. SetSqlDbType (SqlDbType.Decimal);
  333. break;
  334. case "System.Double":
  335. SetSqlDbType (SqlDbType.Float);
  336. break;
  337. case "System.Byte[]":
  338. SetSqlDbType (SqlDbType.VarBinary);
  339. break;
  340. case "System.Byte":
  341. SetSqlDbType (SqlDbType.TinyInt);
  342. break;
  343. case "System.Int32":
  344. SetSqlDbType (SqlDbType.Int);
  345. break;
  346. case "System.Single":
  347. SetSqlDbType (SqlDbType.Real);
  348. break;
  349. case "System.Int16":
  350. SetSqlDbType (SqlDbType.SmallInt);
  351. break;
  352. case "System.Guid":
  353. SetSqlDbType (SqlDbType.UniqueIdentifier);
  354. break;
  355. case "System.Object":
  356. SetSqlDbType (SqlDbType.Variant);
  357. break;
  358. default:
  359. throw new ArgumentException (exception);
  360. }
  361. }
  362. // When the DbType is set, we also set the SqlDbType, as well as the SQL Server
  363. // string representation of the type name. If the DbType is not convertible
  364. // to an SqlDbType, throw an exception.
  365. private void SetDbType (DbType type)
  366. {
  367. string exception = String.Format ("No mapping exists from DbType {0} to a known SqlDbType.", type);
  368. switch (type) {
  369. case DbType.AnsiString:
  370. MetaParameter.TypeName = "varchar";
  371. sqlDbType = SqlDbType.VarChar;
  372. break;
  373. case DbType.AnsiStringFixedLength:
  374. MetaParameter.TypeName = "char";
  375. sqlDbType = SqlDbType.Char;
  376. break;
  377. case DbType.Binary:
  378. MetaParameter.TypeName = "varbinary";
  379. sqlDbType = SqlDbType.VarBinary;
  380. break;
  381. case DbType.Boolean:
  382. MetaParameter.TypeName = "bit";
  383. sqlDbType = SqlDbType.Bit;
  384. break;
  385. case DbType.Byte:
  386. MetaParameter.TypeName = "tinyint";
  387. sqlDbType = SqlDbType.TinyInt;
  388. break;
  389. case DbType.Currency:
  390. sqlDbType = SqlDbType.Money;
  391. MetaParameter.TypeName = "money";
  392. break;
  393. case DbType.Date:
  394. case DbType.DateTime:
  395. MetaParameter.TypeName = "datetime";
  396. sqlDbType = SqlDbType.DateTime;
  397. break;
  398. case DbType.Decimal:
  399. MetaParameter.TypeName = "decimal";
  400. sqlDbType = SqlDbType.Decimal;
  401. break;
  402. case DbType.Double:
  403. MetaParameter.TypeName = "float";
  404. sqlDbType = SqlDbType.Float;
  405. break;
  406. case DbType.Guid:
  407. MetaParameter.TypeName = "uniqueidentifier";
  408. sqlDbType = SqlDbType.UniqueIdentifier;
  409. break;
  410. case DbType.Int16:
  411. MetaParameter.TypeName = "smallint";
  412. sqlDbType = SqlDbType.SmallInt;
  413. break;
  414. case DbType.Int32:
  415. MetaParameter.TypeName = "int";
  416. sqlDbType = SqlDbType.Int;
  417. break;
  418. case DbType.Int64:
  419. MetaParameter.TypeName = "bigint";
  420. sqlDbType = SqlDbType.BigInt;
  421. break;
  422. case DbType.Object:
  423. MetaParameter.TypeName = "sql_variant";
  424. sqlDbType = SqlDbType.Variant;
  425. break;
  426. case DbType.Single:
  427. MetaParameter.TypeName = "real";
  428. sqlDbType = SqlDbType.Real;
  429. break;
  430. case DbType.String:
  431. MetaParameter.TypeName = "nvarchar";
  432. sqlDbType = SqlDbType.NVarChar;
  433. break;
  434. case DbType.StringFixedLength:
  435. MetaParameter.TypeName = "nchar";
  436. sqlDbType = SqlDbType.NChar;
  437. break;
  438. case DbType.Time:
  439. MetaParameter.TypeName = "datetime";
  440. sqlDbType = SqlDbType.DateTime;
  441. break;
  442. default:
  443. throw new ArgumentException (exception);
  444. }
  445. dbType = type;
  446. }
  447. // Used by internal constructor which has a SQL Server typename
  448. private void SetDbTypeName (string dbTypeName)
  449. {
  450. switch (dbTypeName.ToLower ()) {
  451. case "bigint":
  452. SqlDbType = SqlDbType.BigInt;
  453. break;
  454. case "binary":
  455. SqlDbType = SqlDbType.Binary;
  456. break;
  457. case "bit":
  458. SqlDbType = SqlDbType.Bit;
  459. break;
  460. case "char":
  461. SqlDbType = SqlDbType.Char;
  462. break;
  463. case "datetime":
  464. SqlDbType = SqlDbType.DateTime;
  465. break;
  466. case "decimal":
  467. SqlDbType = SqlDbType.Decimal;
  468. break;
  469. case "float":
  470. SqlDbType = SqlDbType.Float;
  471. break;
  472. case "image":
  473. SqlDbType = SqlDbType.Image;
  474. break;
  475. case "int":
  476. SqlDbType = SqlDbType.Int;
  477. break;
  478. case "money":
  479. SqlDbType = SqlDbType.Money;
  480. break;
  481. case "nchar":
  482. SqlDbType = SqlDbType.NChar;
  483. break;
  484. case "ntext":
  485. SqlDbType = SqlDbType.NText;
  486. break;
  487. case "nvarchar":
  488. SqlDbType = SqlDbType.NVarChar;
  489. break;
  490. case "real":
  491. SqlDbType = SqlDbType.Real;
  492. break;
  493. case "smalldatetime":
  494. SqlDbType = SqlDbType.SmallDateTime;
  495. break;
  496. case "smallint":
  497. SqlDbType = SqlDbType.SmallInt;
  498. break;
  499. case "smallmoney":
  500. SqlDbType = SqlDbType.SmallMoney;
  501. break;
  502. case "text":
  503. SqlDbType = SqlDbType.Text;
  504. break;
  505. case "timestamp":
  506. SqlDbType = SqlDbType.Timestamp;
  507. break;
  508. case "tinyint":
  509. SqlDbType = SqlDbType.TinyInt;
  510. break;
  511. case "uniqueidentifier":
  512. SqlDbType = SqlDbType.UniqueIdentifier;
  513. break;
  514. case "varbinary":
  515. SqlDbType = SqlDbType.VarBinary;
  516. break;
  517. case "varchar":
  518. SqlDbType = SqlDbType.VarChar;
  519. break;
  520. default:
  521. SqlDbType = SqlDbType.Variant;
  522. break;
  523. }
  524. }
  525. // When the SqlDbType is set, we also set the DbType, as well as the SQL Server
  526. // string representation of the type name. If the SqlDbType is not convertible
  527. // to a DbType, throw an exception.
  528. private void SetSqlDbType (SqlDbType type)
  529. {
  530. string exception = String.Format ("No mapping exists from SqlDbType {0} to a known DbType.", type);
  531. switch (type) {
  532. case SqlDbType.BigInt:
  533. MetaParameter.TypeName = "bigint";
  534. dbType = DbType.Int64;
  535. break;
  536. case SqlDbType.Binary:
  537. MetaParameter.TypeName = "binary";
  538. dbType = DbType.Binary;
  539. break;
  540. case SqlDbType.Timestamp:
  541. MetaParameter.TypeName = "timestamp";
  542. dbType = DbType.Binary;
  543. break;
  544. case SqlDbType.VarBinary:
  545. MetaParameter.TypeName = "varbinary";
  546. dbType = DbType.Binary;
  547. break;
  548. case SqlDbType.Bit:
  549. MetaParameter.TypeName = "bit";
  550. dbType = DbType.Boolean;
  551. break;
  552. case SqlDbType.Char:
  553. MetaParameter.TypeName = "char";
  554. dbType = DbType.AnsiStringFixedLength;
  555. break;
  556. case SqlDbType.DateTime:
  557. MetaParameter.TypeName = "datetime";
  558. dbType = DbType.DateTime;
  559. break;
  560. case SqlDbType.SmallDateTime:
  561. MetaParameter.TypeName = "smalldatetime";
  562. dbType = DbType.DateTime;
  563. break;
  564. case SqlDbType.Decimal:
  565. MetaParameter.TypeName = "decimal";
  566. dbType = DbType.Decimal;
  567. break;
  568. case SqlDbType.Float:
  569. MetaParameter.TypeName = "float";
  570. dbType = DbType.Double;
  571. break;
  572. case SqlDbType.Image:
  573. MetaParameter.TypeName = "image";
  574. dbType = DbType.Binary;
  575. break;
  576. case SqlDbType.Int:
  577. MetaParameter.TypeName = "int";
  578. dbType = DbType.Int32;
  579. break;
  580. case SqlDbType.Money:
  581. MetaParameter.TypeName = "money";
  582. dbType = DbType.Currency;
  583. break;
  584. case SqlDbType.SmallMoney:
  585. MetaParameter.TypeName = "smallmoney";
  586. dbType = DbType.Currency;
  587. break;
  588. case SqlDbType.NChar:
  589. MetaParameter.TypeName = "nchar";
  590. dbType = DbType.StringFixedLength;
  591. break;
  592. case SqlDbType.NText:
  593. MetaParameter.TypeName = "ntext";
  594. dbType = DbType.String;
  595. break;
  596. case SqlDbType.NVarChar:
  597. MetaParameter.TypeName = "nvarchar";
  598. dbType = DbType.String;
  599. break;
  600. case SqlDbType.Real:
  601. MetaParameter.TypeName = "real";
  602. dbType = DbType.Single;
  603. break;
  604. case SqlDbType.SmallInt:
  605. MetaParameter.TypeName = "smallint";
  606. dbType = DbType.Int16;
  607. break;
  608. case SqlDbType.Text:
  609. MetaParameter.TypeName = "text";
  610. dbType = DbType.AnsiString;
  611. break;
  612. case SqlDbType.VarChar:
  613. MetaParameter.TypeName = "varchar";
  614. dbType = DbType.AnsiString;
  615. break;
  616. case SqlDbType.TinyInt:
  617. MetaParameter.TypeName = "tinyint";
  618. dbType = DbType.Byte;
  619. break;
  620. case SqlDbType.UniqueIdentifier:
  621. MetaParameter.TypeName = "uniqueidentifier";
  622. dbType = DbType.Guid;
  623. break;
  624. case SqlDbType.Variant:
  625. MetaParameter.TypeName = "sql_variant";
  626. dbType = DbType.Object;
  627. break;
  628. default:
  629. throw new ArgumentException (exception);
  630. }
  631. sqlDbType = type;
  632. }
  633. public override string ToString()
  634. {
  635. return ParameterName;
  636. }
  637. #if NET_2_0
  638. [MonoTODO]
  639. public override void CopyTo (DbParameter param)
  640. {
  641. throw new NotImplementedException ();
  642. }
  643. [MonoTODO]
  644. public override void ResetDbType ()
  645. {
  646. throw new NotImplementedException ();
  647. }
  648. #endif // NET_2_0
  649. #endregion // Methods
  650. }
  651. }