當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。