public void Write(DbField param)
		{
			try
			{
				if (param.DbDataType != DbDataType.Null)
				{
					param.FixNull();

					switch (param.DbDataType)
					{
						case DbDataType.Char:
							if (param.Charset.IsOctetsCharset)
							{
								this.WriteOpaque(param.DbValue.GetBinary(), param.Length);
							}
							else
							{
								string svalue = param.DbValue.GetString();

								if ((param.Length % param.Charset.BytesPerCharacter) == 0 &&
									svalue.Length > param.CharCount)
								{
									throw new IscException(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });
								}

								this.WriteOpaque(param.Charset.GetBytes(svalue), param.Length);
							}
							break;

						case DbDataType.VarChar:
							if (param.Charset.IsOctetsCharset)
							{
								this.WriteOpaque(param.DbValue.GetBinary(), param.Length);
							}
							else
							{
								string svalue = param.DbValue.GetString();

								if ((param.Length % param.Charset.BytesPerCharacter) == 0 &&
									svalue.Length > param.CharCount)
								{
									throw new IscException(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });
								}

								byte[] data = param.Charset.GetBytes(svalue);

								this.WriteBuffer(data, data.Length);
							}
							break;

						case DbDataType.SmallInt:
							this.Write(param.DbValue.GetInt16());
							break;

						case DbDataType.Integer:
							this.Write(param.DbValue.GetInt32());
							break;

						case DbDataType.BigInt:
						case DbDataType.Array:
						case DbDataType.Binary:
						case DbDataType.Text:
							this.Write(param.DbValue.GetInt64());
							break;

						case DbDataType.Decimal:
						case DbDataType.Numeric:
							this.Write(
								param.DbValue.GetDecimal(),
								param.DataType,
								param.NumericScale);
							break;

						case DbDataType.Float:
							this.Write(param.DbValue.GetFloat());
							break;

						case DbDataType.Guid:
							this.WriteOpaque(param.DbValue.GetGuid().ToByteArray());
							break;

						case DbDataType.Double:
							this.Write(param.DbValue.GetDouble());
							break;

						case DbDataType.Date:
							this.Write(param.DbValue.GetDate());
							break;

						case DbDataType.Time:
							this.Write(param.DbValue.GetTime());
							break;

						case DbDataType.TimeStamp:
							this.Write(param.DbValue.GetDate());
							this.Write(param.DbValue.GetTime());
							break;

						case DbDataType.Boolean:
							this.Write(Convert.ToBoolean(param.Value));
							break;

						default:
							throw new IscException("Unknown sql data type: " + param.DataType);
					}
				}

				this.Write(param.NullFlag);
			}
			catch (IOException)
			{
				throw new IscException(IscCodes.isc_net_write_err);
			}
		}
		public void Write(DbField param)
		{
			Charset innerCharset = (this.charset.Name != "NONE") ? this.charset : param.Charset;

			param.FixNull();

			try
			{
				switch (param.DbDataType)
				{
					case DbDataType.Char:
						{
							string svalue = param.DbValue.GetString();

							if ((param.Length % param.Charset.BytesPerCharacter) == 0 &&
								svalue.Length > param.CharCount)
							{
								throw new IscException(335544321);
							}

							this.WriteOpaque(innerCharset.GetBytes(svalue), param.Length);
						}
						break;

					case DbDataType.VarChar:
						{
							string svalue = param.DbValue.GetString().TrimEnd();

							if ((param.Length % param.Charset.BytesPerCharacter) == 0 &&
								svalue.Length > param.CharCount)
							{
								throw new IscException(335544321);
							}

							byte[] data = innerCharset.GetBytes(svalue);

							this.WriteBuffer(data, data.Length);
						}
						break;

					case DbDataType.SmallInt:
						this.Write(param.DbValue.GetInt16());
						break;

					case DbDataType.Integer:
						this.Write(param.DbValue.GetInt32());
						break;

					case DbDataType.BigInt:
					case DbDataType.Array:
					case DbDataType.Binary:
					case DbDataType.Text:
						this.Write(param.DbValue.GetInt64());
						break;

					case DbDataType.Decimal:
					case DbDataType.Numeric:
						this.Write(
							param.DbValue.GetDecimal(),
							param.DataType,
							param.NumericScale);
						break;

					case DbDataType.Float:
						this.Write(param.DbValue.GetFloat());
						break;

					case DbDataType.Guid:
						this.WriteOpaque(param.DbValue.GetGuid().ToByteArray());
						break;

					case DbDataType.Double:
						this.Write(param.DbValue.GetDouble());
						break;

					case DbDataType.Date:
						this.Write(param.DbValue.EncodeDate());
						break;

					case DbDataType.Time:
						this.Write(param.DbValue.EncodeTime());
						break;

					case DbDataType.TimeStamp:
						this.Write(param.DbValue.EncodeDate());
						this.Write(param.DbValue.EncodeTime());
						break;

					default:
						throw new IscException("Unknown sql data type: " + param.DataType);
				}

				this.Write(param.NullFlag);
			}
			catch (IOException)
			{
				throw new IscException(IscCodes.isc_net_write_err);
			}
		}