本文整理汇总了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();
}
示例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();
}
示例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;
}
}
示例4: SafeGetInt
public static int SafeGetInt(MySqlDataReader reader, string colName)
{
if (!reader.IsDBNull(reader.GetOrdinal(colName)))
return reader.GetInt32(colName);
else
return default(int);
}
示例5: SafeGetString
/*----------------------UTILITY------------------------*/
public static String SafeGetString(MySqlDataReader reader, int colIndex)
{
if (!reader.IsDBNull(colIndex))
return reader.GetString(colIndex);
else
return string.Empty;
}
示例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();
}
}
示例7: SafeGetDateTime
public static DateTime SafeGetDateTime(MySqlDataReader reader, int colIndex)
{
if (!reader.IsDBNull(colIndex))
return reader.GetDateTime(colIndex);
else
return default(DateTime);
}
示例8: checkNull
public String checkNull(MySqlDataReader reader, Int16 index)
{
if (reader.IsDBNull(index))
{
return null;
}
return reader.GetValue(index).ToString();
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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"));
}