本文整理汇总了C#中MySql.Data.MySqlClient.MySqlDataReader.GetOrdinal方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlDataReader.GetOrdinal方法的具体用法?C# MySqlDataReader.GetOrdinal怎么用?C# MySqlDataReader.GetOrdinal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySql.Data.MySqlClient.MySqlDataReader
的用法示例。
在下文中一共展示了MySqlDataReader.GetOrdinal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SafeGetString
public static String SafeGetString(MySqlDataReader reader, string colName)
{
if (!reader.IsDBNull(reader.GetOrdinal(colName)))
return reader.GetString(colName);
else
return string.Empty;
}
示例2: 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;
}
}
示例3: SafeGetDateTime
public static DateTime SafeGetDateTime(MySqlDataReader reader, string colName)
{
if (!reader.IsDBNull(reader.GetOrdinal(colName)))
return reader.GetDateTime(colName);
else
return default(DateTime);
}
示例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: Logar
public bool Logar(string nickname, string senha)
{
Conexao();
bool logado = false;
string sql = "select id, nickname, senha from Usuario where nickname= @nickname ";
command = new MySqlCommand(sql, Conexao());
par = new MySqlParameter("@nickname", nickname);
par.MySqlDbType = MySqlDbType.VarChar;
command.Parameters.Add(par);
reader = command.ExecuteReader();
string senhaUsuario;
if (reader.Read())
{
senhaUsuario = reader.GetValue(reader.GetOrdinal("SENHA")).ToString();
if (senhaUsuario.Equals(senha))
{
logado = true;
}
}
FecharConexao();
return logado;
// command = new System.Data.SqlClient.SqlCommand(sql, conexão());
}
示例6: 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;
}
示例7: 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;
}
示例8: GetUsuario
public static Usuario GetUsuario(MySqlDataReader rdr)
{
if (rdr.IsDBNull(rdr.GetOrdinal("CODUSU"))) return null;
Usuario u = new Usuario();
u.CodUsu = rdr.GetInt32("CODUSU");
u.NomUsu = rdr.GetString("NOMUSU");
u.Login = rdr.GetString("LOGIN");
u.PasswordPropio = rdr.GetString("PASSWORD_PROPIO");
u.NivelAriges = rdr.GetInt32("NIVEL_ARIGES");
return u;
}
示例9: GetAlbaran
public static Albaran GetAlbaran(MySqlDataReader rdr)
{
if (rdr.IsDBNull(rdr.GetOrdinal("NUMALBAR")))
return null;
Albaran a = new Albaran();
a.CodTipom = rdr.GetString("CODTIPOM");
a.NumAlbar = rdr.GetInt32("NUMALBAR");
a.FechaAlb = rdr.GetDateTime("FECHAALB");
a.TotalAlb = rdr.GetDecimal("TOTALALB");
return a;
}
示例10: GetMySQLDateTime
public static DateTime GetMySQLDateTime(MySqlDataReader mySQLDataReader, String column)
{
DateTime dateTime = DateTime.MinValue;
try
{
int index = mySQLDataReader.GetOrdinal(column);
if (!mySQLDataReader.IsDBNull(index))
{
MySqlDateTime mySQLDateTime = mySQLDataReader.GetMySqlDateTime(column);
if (mySQLDateTime.Day > 0)
{
dateTime = mySQLDateTime.GetDateTime();
}
}
}
catch (Exception ex)
{
log.Error(ex.Message);
}
return dateTime;
}
示例11: getDouble
public static double? getDouble(MySqlDataReader dr, string column)
{
int ordinal = dr.GetOrdinal(column);
if (dr.IsDBNull(ordinal))
{
return null;
}
else
{
return dr.GetDouble(ordinal);
}
}
示例12: getBool
public static bool? getBool(MySqlDataReader dr, string column)
{
int ordinal = dr.GetOrdinal(column);
if (dr.IsDBNull(ordinal))
{
return null;
}
else
{
return dr.GetBoolean(ordinal);
}
}
示例13: _readDateTimeField
private static DateTime _readDateTimeField(MySqlDataReader dataReader, string fieldName)
{
DateTime result = default(DateTime);
try
{
result = dataReader.IsDBNull(dataReader.GetOrdinal(fieldName)) ? default(DateTime) : DateTime.SpecifyKind(dataReader.GetDateTime(fieldName), DateTimeKind.Utc);
}
catch (Exception e)
{
Debug.WriteLine(e.Message, e.StackTrace);
}
return result;
}
示例14: _readArchiveMedia
private static ArchiveMedia _readArchiveMedia(MySqlDataReader dataReader, ArchiveDirectory dir)
{
byte typVideo = dataReader.IsDBNull(dataReader.GetOrdinal("typVideo")) ? (byte)0 : dataReader.GetByte("typVideo");
ArchiveMedia media = new ArchiveMedia()
{
idPersistentMedia = dataReader.GetUInt64("idArchiveMedia"),
Directory = dir,
};
_mediaReadFields(dataReader, media);
ThreadPool.QueueUserWorkItem(o => media.Verify());
return media;
}
示例15: _mediaReadFields
private static void _mediaReadFields(MySqlDataReader dataReader, PersistentMedia media)
{
uint flags = dataReader.IsDBNull(dataReader.GetOrdinal("flags")) ? (uint)0 : dataReader.GetUInt32("flags");
byte typVideo = dataReader.IsDBNull(dataReader.GetOrdinal("typVideo")) ? (byte)0 : dataReader.GetByte("typVideo");
media._mediaName = dataReader.IsDBNull(dataReader.GetOrdinal("MediaName")) ? string.Empty : dataReader.GetString("MediaName");
media._duration = dataReader.IsDBNull(dataReader.GetOrdinal("Duration")) ? default(TimeSpan) : dataReader.GetTimeSpan("Duration");
media._durationPlay = dataReader.IsDBNull(dataReader.GetOrdinal("DurationPlay")) ? default(TimeSpan) : dataReader.GetTimeSpan("DurationPlay");
media._folder = dataReader.IsDBNull(dataReader.GetOrdinal("Folder")) ? string.Empty : dataReader.GetString("Folder");
media._fileName = dataReader.IsDBNull(dataReader.GetOrdinal("FileName")) ? string.Empty : dataReader.GetString("FileName");
media._fileSize = dataReader.IsDBNull(dataReader.GetOrdinal("FileSize")) ? 0 : dataReader.GetUInt64("FileSize");
media.idFormat = dataReader.IsDBNull(dataReader.GetOrdinal("idFormat")) ? 0 : dataReader.GetUInt64("idFormat");
media._lastUpdated = _readDateTimeField(dataReader, "LastUpdated");
media._mediaStatus = (TMediaStatus)(dataReader.IsDBNull(dataReader.GetOrdinal("statusMedia")) ? 0 : dataReader.GetInt32("statusMedia"));
media._mediaType = (TMediaType)(dataReader.IsDBNull(dataReader.GetOrdinal("typMedia")) ? 0 : dataReader.GetInt32("typMedia"));
media._tCStart = dataReader.IsDBNull(dataReader.GetOrdinal("TCStart")) ? default(TimeSpan) : dataReader.GetTimeSpan("TCStart");
media._tCPlay = dataReader.IsDBNull(dataReader.GetOrdinal("TCPlay")) ? default(TimeSpan) : dataReader.GetTimeSpan("TCPlay");
media.idProgramme = dataReader.IsDBNull(dataReader.GetOrdinal("idProgramme")) ? 0 : dataReader.GetUInt64("idProgramme");
media._audioVolume = dataReader.IsDBNull(dataReader.GetOrdinal("AudioVolume")) ? 0 : dataReader.GetDecimal("AudioVolume");
media._audioLevelIntegrated = dataReader.IsDBNull(dataReader.GetOrdinal("AudioLevelIntegrated")) ? 0 : dataReader.GetDecimal("AudioLevelIntegrated");
media._audioLevelPeak = dataReader.IsDBNull(dataReader.GetOrdinal("AudioLevelPeak")) ? 0 : dataReader.GetDecimal("AudioLevelPeak");
media._audioChannelMapping = dataReader.IsDBNull(dataReader.GetOrdinal("typAudio")) ? TAudioChannelMapping.Stereo : (TAudioChannelMapping)dataReader.GetByte("typAudio");
media.HasExtraLines = (typVideo & (byte)0x80) > 0;
media._videoFormat = (TVideoFormat)(typVideo & 0x7F);
media._idAux = dataReader.IsDBNull(dataReader.GetOrdinal("idAux")) ? string.Empty : dataReader.GetString("idAux");
media._killDate = _readDateTimeField(dataReader, "KillDate");
media._mediaGuid = dataReader.IsDBNull(dataReader.GetOrdinal("MediaGuid")) ? Guid.Empty : dataReader.GetGuid("MediaGuid");
media._mediaEmphasis = (TMediaEmphasis)((flags >> 8) & 0xF);
media._parental = (TParental)((flags >> 12) & 0xF);
if (media is ServerMedia)
((ServerMedia)media)._doNotArchive = (flags & 0x1) != 0;
media._mediaCategory = (TMediaCategory)((flags >> 4) & 0xF); // bits 4-7 of 1st byte
}