Exemplo n.º 1
0
        private void AdjustOutputTypes(MySqlDataReader reader)
        {
            // since MySQL likes to return user variables as strings
              // we reset the types of the readers internal value objects
              // this will allow those value objects to parse the string based
              // return values
              for (int i = 0; i < reader.FieldCount; i++)
              {
            string fieldName = reader.GetName(i);
            if (fieldName.IndexOf(StoredProcedure.ParameterPrefix) != -1)
              fieldName = fieldName.Remove(0, StoredProcedure.ParameterPrefix.Length + 1);
            MySqlParameter parameter = command.Parameters.GetParameterFlexible(fieldName, true);

            IMySqlValue v = MySqlField.GetIMySqlValue(parameter.MySqlDbType);
            if (v is MySqlBit)
            {
              MySqlBit bit = (MySqlBit)v;
              bit.ReadAsString = true;
              reader.ResultSet.SetValueObject(i, bit);
            }
            else
              reader.ResultSet.SetValueObject(i, v);
              }
        }
Exemplo n.º 2
0
        internal void ProcessOutputParameters(MySqlDataReader reader)
        {
            // We apparently need to always adjust our output types since the server
              // provided data types are not always right
              AdjustOutputTypes(reader);

              if ((reader.CommandBehavior & CommandBehavior.SchemaOnly) != 0)
            return;

              // now read the output parameters data row
              reader.Read();

              string prefix = "@" + StoredProcedure.ParameterPrefix;

              for (int i = 0; i < reader.FieldCount; i++)
              {
            string fieldName = reader.GetName(i);
            if (fieldName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
              fieldName = fieldName.Remove(0, prefix.Length);
            MySqlParameter parameter = command.Parameters.GetParameterFlexible(fieldName, true);
            parameter.Value = reader.GetValue(i);
              }
        }