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


C# MySqlDataReader.IsDBNull方法代码示例

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


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

示例1: findAll

        public void findAll()
        {
            db = new Database();

            brands.Clear();

            brandQuery = new MySqlCommand();

            brandQuery.Connection = db.Connection();

            brandQuery.CommandText = "SELECT * FROM brand ORDER BY brandname ASC";

            this.brandResult = brandQuery.ExecuteReader();

            while (brandResult.Read())
            {
                if (!brandResult.IsDBNull(0))
                {
                    idbrand = brandResult.GetInt32(0);
                }

                if (!brandResult.IsDBNull(1))
                {
                    brandname = brandResult.GetString(1);
                }

                brands.Add(new Brand { idbrand = this.idbrand, brandname = this.brandname});
            }

            db.Close();
        }
开发者ID:JoseMariaAndrade,项目名称:VeneporteProject,代码行数:31,代码来源:Brand.cs

示例2: findAll

        public void findAll()
        {
            db = new Database();

            person_user_computerQuery = new MySqlCommand();

            person_user_computerQuery.Connection = db.Connection();

            person_user_computerQuery.CommandText = "SELECT * FROM person_user_computer";

            person_user_computerResult = person_user_computerQuery.ExecuteReader();

            while (person_user_computerResult.Read())
            {
                if (!person_user_computerResult.IsDBNull(0))
                {
                    idperson_user = person_user_computerResult.GetInt32(0);
                }

                if (!person_user_computerResult.IsDBNull(1))
                {
                    person = new Person();

                    person.idperson = person_user_computerResult.GetInt32(1);

                    person.findByIdperson();
                }

                if (!person_user_computerResult.IsDBNull(2))
                {
                    user = new User();

                    user.iduser = person_user_computerResult.GetInt32(2);

                    user.findByIdUser();
                }

                //if (!person_user_computerResult.IsDBNull(3))
                //{
                //    person_userstart = person_user_computerResult.GetDateTime(3);
                //}
                //else
                //{
                //    person_userstart = null;
                //}

                //if (!person_user_computerResult.IsDBNull(4))
                //{
                //    person_userfinish = person_user_computerResult.GetDateTime(4);
                //}
                //else
                //{
                //    person_userfinish = null;
                //}

                persons_users_computers.Add(new Person_User_Computer { idperson_user = this.idperson_user, person = this.person, user = this.user });
            }

            db.Close();
        }
开发者ID:JoseMariaAndrade,项目名称:VeneporteProject,代码行数:60,代码来源:Person_User_Computer.cs

示例3: convertBlobToBufferData

        public static byte[] convertBlobToBufferData(String column,MySqlDataReader rdr)
        {
            int bufferSize = 1024; // Number of bytes to read at a time
            byte[] ImageData = new byte[bufferSize];
            long nBytesReturned, startIndex = 0;
            int ordinal = rdr.GetOrdinal(column);
            string image = rdr.IsDBNull(ordinal) ? null : rdr.GetString(column);
            if (image != null)
            {
                startIndex = 0;

                nBytesReturned = rdr.GetBytes(
                ordinal, // Column index of BLOB column
                startIndex, // Start position of the byte to read
                ImageData, // Byte array to recieve BLOB data
                0, // Start index of the array
                bufferSize // Size of buffer
                );
                while (nBytesReturned == bufferSize)
                {
                    startIndex += bufferSize;
                    nBytesReturned = rdr.GetBytes(ordinal, startIndex, ImageData, 0, bufferSize); // Number of bytes returned is assigned to nBytesReturned
                }
                return ImageData;
            }
            else
            {
                return null;
            }
        }
开发者ID:geekprogramming,项目名称:GPManagement,代码行数:30,代码来源:ConvertUtil.cs

示例4: SafeGetInt

 public static int SafeGetInt(MySqlDataReader reader, string colName)
 {
     if (!reader.IsDBNull(reader.GetOrdinal(colName)))
         return reader.GetInt32(colName);
     else
         return default(int);
 }
开发者ID:CalumMurray,项目名称:TBCN,代码行数:7,代码来源:DatabaseConnection.cs

示例5: SafeGetString

 /*----------------------UTILITY------------------------*/
 public static String SafeGetString(MySqlDataReader reader, int colIndex)
 {
     if (!reader.IsDBNull(colIndex))
         return reader.GetString(colIndex);
     else
         return string.Empty;
 }
开发者ID:CalumMurray,项目名称:TBCN,代码行数:8,代码来源:DatabaseConnection.cs

示例6: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            con.Open();
            cmduser = new MySqlCommand("select login_prev,login_curr from login_hist where login_name='" + Session["loginname"].ToString()+"'" , con);
            druser = cmduser.ExecuteReader();
            druser.Read();
            if (druser.IsDBNull(0))
            {
                logdate.Text = druser.GetDateTime("login_curr").ToShortDateString();
                logtime.Text = druser.GetDateTime("login_curr").ToShortTimeString();
            }
            else
            {
                logdate.Text = druser.GetDateTime("login_prev").ToShortDateString();
                logtime.Text = druser.GetDateTime("login_prev").ToShortTimeString();
            }

            druser.Close();

           }
        catch (Exception ex)
        {
            CreateLogFile log1 = new CreateLogFile();
            log1.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Page Load method of Admin_Index for " + Session["loginname"] + ":" + ex.Message);
        }
        finally
        {
            con.Close();
        }
    }
开发者ID:vivek9088,项目名称:Alumni-Website,代码行数:32,代码来源:Admin_index.aspx.cs

示例7: SafeGetDateTime

 public static DateTime SafeGetDateTime(MySqlDataReader reader, int colIndex)
 {
     if (!reader.IsDBNull(colIndex))
         return reader.GetDateTime(colIndex);
     else
         return default(DateTime);
 }
开发者ID:CalumMurray,项目名称:TBCN,代码行数:7,代码来源:DatabaseConnection.cs

示例8: checkNull

 public String checkNull(MySqlDataReader reader, Int16 index)
 {
     if (reader.IsDBNull(index))
     {
         return null;
     }
     return reader.GetValue(index).ToString();
 }
开发者ID:pctjose,项目名称:OpenMRStoACCESS,代码行数:8,代码来源:InsertUtils.cs

示例9: SafeGetString

 public static String SafeGetString(MySqlDataReader reader, String columnname)
 {
     int colIndex = reader.GetOrdinal(columnname);
     if (!reader.IsDBNull(colIndex))
         return reader.GetString(colIndex);
     else
         return String.Empty;
 }
开发者ID:KH4IT,项目名称:MakeOver-Paris,代码行数:8,代码来源:DBUtility.cs

示例10: Map

 public Tag Map(MySqlDataReader reader)
 {
     Tag tag = new Tag();
     tag.Id = reader.GetInt32("id");
     tag.Tagname = reader.GetString("tagname");
     tag.TagCount = reader.IsDBNull(2) ? (int?)null : reader.GetInt32(2);
     return tag;
 }
开发者ID:Steven1988,项目名称:portfolio-2,代码行数:8,代码来源:TagMapper.cs

示例11: Read

 public static void Read( object O,TPropertyMapper M,MySqlDataReader reader)
 {
     foreach (TPropertyMapping Map in M)
     {
         if (!reader.IsDBNull(Map.FieldNum))
             Map.PInfo.SetValue(O, Convert.ChangeType(reader[Map.FieldName], Map.PInfo.PropertyType), null);
     }
 }
开发者ID:Warlord123,项目名称:RdpTools,代码行数:8,代码来源:ObjectLoader.cs

示例12: DBColumnToPyObject

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

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

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

示例13: GetAgente

 public static Agente GetAgente(MySqlDataReader rdr)
 {
     if (rdr.IsDBNull(rdr.GetOrdinal("CODAGENT")))
         return null;
     Agente a = new Agente();
     a.CodAgent = rdr.GetInt32("CODAGENT");
     a.NomAgent = rdr.GetString("NOMAGENT");
     return a;
 }
开发者ID:rafaelgr,项目名称:ArigesMovil,代码行数:9,代码来源:CntAriGes.cs

示例14: LoadFromDB

 public void LoadFromDB(MySqlDataReader reader)
 {
     if (reader.Read())
     {
         Nickname = (reader.IsDBNull(0) ? null : reader.GetString(0));
         Level = reader.GetInt16(1);
         Exp = reader.GetInt16(2);
     }
 }
开发者ID:SyncZone,项目名称:IndieAPI,代码行数:9,代码来源:UserProfile.cs

示例15: CoulomnInformations

        public CoulomnInformations(MySqlDataReader reader)
        {
            this._Field = reader.GetString(reader.GetOrdinal("Field"));
            this._Type = reader.GetString(reader.GetOrdinal("Type"));
            if (!reader.IsDBNull(reader.GetOrdinal("Collation")))
            {
                this._Collation = reader.GetString(reader.GetOrdinal("Collation"));
            }

            this._Null = reader.GetString(reader.GetOrdinal("Null"));
            this._Key = reader.GetString(reader.GetOrdinal("Key"));
            if (!reader.IsDBNull(reader.GetOrdinal("Default")))
            {
                this._Default = reader.GetString(reader.GetOrdinal("Default"));
            }
            this._Extra = reader.GetString(reader.GetOrdinal("Extra"));
            this._Privileges = reader.GetString(reader.GetOrdinal("Privileges"));
            this._Comment = reader.GetString(reader.GetOrdinal("Comment"));
        }
开发者ID:karpediemnow,项目名称:mysql-class-generator,代码行数:19,代码来源:CoulomnInformations.cs


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