当前位置: 首页>>代码示例>>C#>>正文


C# MySqlDataReader.GetFieldType方法代码示例

本文整理汇总了C#中MySql.Data.MySqlClient.MySqlDataReader.GetFieldType方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlDataReader.GetFieldType方法的具体用法?C# MySqlDataReader.GetFieldType怎么用?C# MySqlDataReader.GetFieldType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MySql.Data.MySqlClient.MySqlDataReader的用法示例。


在下文中一共展示了MySqlDataReader.GetFieldType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DBColumnToPyObject

        public static PyObject DBColumnToPyObject(int index, ref MySqlDataReader reader)
        {
            Type type = reader.GetFieldType(index);

            switch (type.Name)
            {
                case "String":
                    return new PyString(reader.GetString(index));
                case "UInt32":
                case "Int32":
                case "UInt16":
                case "Int16":
                case "SByte":
                case "Byte":
                    return new PyInt(reader.GetInt32(index));
                case "UInt64":
                case "Int64":
                    return new PyLongLong(reader.GetInt64(index));
                case "Byte[]":
                    return new PyBuffer((byte[])reader.GetValue(index));
                case "Double":
                    return new PyFloat(reader.GetDouble(index));
                case "Decimal":
                    return new PyFloat((double)reader.GetDecimal(index));
                case "Boolean":
                    return new PyBool(reader.GetBoolean(index));
                default:
                    Log.Error("Database", "Unhandled MySQL type " + type.Name);
                    break;
            }

            return null;
        }
开发者ID:Reve,项目名称:EVESharp,代码行数:33,代码来源:DBUtils.cs

示例2: GetSchemaFromReader

        /// <summary>
        /// Gets CRUD schema from MySqlReader per particular QuerySource.
        /// If source is null then all columns from reader are copied.
        /// Note: this code was purposely made provider specific because other providers may treat some nuances differently
        /// </summary>
        public static Schema GetSchemaFromReader(string name, QuerySource source, MySqlDataReader reader)
        {
            var table = name;
               var fdefs = new List<Schema.FieldDef>();

               for (int i = 0; i < reader.FieldCount; i++)
               {
                    var fname = reader.GetName(i);
                    var ftype = reader.GetFieldType(i);

                    var def = new Schema.FieldDef(fname, ftype, source!=null ? ( source.HasPragma ? source.ColumnDefs[fname] : null) : null);
                    fdefs.Add( def );
               }

               if (source!=null)
                if (source.HasPragma && source.ModifyTarget.IsNotNullOrWhiteSpace()) table = source.ModifyTarget;

               if (table.IsNullOrWhiteSpace()) table = Guid.NewGuid().ToString();

               return new Schema(table, source!=null ? source.ReadOnly : true,  fdefs);
        }
开发者ID:vlapchenko,项目名称:nfx,代码行数:26,代码来源:MySQLCRUDScriptQueryHandler.cs

示例3: GetType

        public FieldType GetType(int index, ref MySqlDataReader reader)
        {
            Type type = reader.GetFieldType(index);

            switch (type.Name)
            {
                case "String":
                    return FieldType.Str;
                case "UInt32":
                    return FieldType.UI4;
                case "Int32":
                    return FieldType.I4;
                case "UInt16":
                    return FieldType.UI2;
                case "Int16":
                    return FieldType.I2;
                case "UInt64":
                    return FieldType.UI8;
                case "Int64":
                    return FieldType.I8;
                case "Byte[]":
                    return FieldType.Bytes;
                case "SByte":
                    return FieldType.I1; ;
                case "Double":
                    return FieldType.R8;
                case "Decimal":
                    return FieldType.R4;
                case "Boolean":
                    return FieldType.Bool;
                case "Byte":
                    return FieldType.UI1;
                default:
                    throw new Exception("Wrong FieldType");
            }
        }
开发者ID:VizanArkonin,项目名称:EVEmu-live-packet-editor,代码行数:36,代码来源:DBRowDescriptor.cs

示例4: GetConvertDataReaderToDataTable

        /// <summary> 
        /// DataReader格式转换成DataTable 
        /// </summary> 
        /// <param name="DataReader">OleDbDataReader</param> 
        private DataTable GetConvertDataReaderToDataTable(MySqlDataReader reader)
        {
            DataTable objDataTable = new DataTable("TmpDataTable");
            int intCounter;

            try
            {
                //获取当前行中的列数;
                int intFieldCount = reader.FieldCount;

                for (intCounter = 0; intCounter <= intFieldCount - 1; intCounter++)
                {
                    objDataTable.Columns.Add(reader.GetName(intCounter), reader.GetFieldType(intCounter));
                }

                //populate   datatable
                objDataTable.BeginLoadData();

                //object[]   objValues   =   new   object[intFieldCount   -1];
                object[] objValues = new object[intFieldCount];

                while (reader.Read())
                {
                    reader.GetValues(objValues);
                    objDataTable.LoadDataRow(objValues, true);
                }
                reader.Close();

                objDataTable.EndLoadData();

                return objDataTable;

            }
            catch (MySqlException ex)
            {
                throw ex;
            }
        }
开发者ID:xlgwr,项目名称:RFID,代码行数:42,代码来源:CMySQLConnect.cs


注:本文中的MySql.Data.MySqlClient.MySqlDataReader.GetFieldType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。