本文整理汇总了C#中IDataReader.GetInt16方法的典型用法代码示例。如果您正苦于以下问题:C# IDataReader.GetInt16方法的具体用法?C# IDataReader.GetInt16怎么用?C# IDataReader.GetInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataReader
的用法示例。
在下文中一共展示了IDataReader.GetInt16方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: mCargarProd
private static EProdXUnd mCargarProd(IDataReader rdr)
{
EProdXUnd oProd = new EProdXUnd();
//oProd.Id_producto = rdr.IsDBNull(rdr.GetOrdinal("id_producto")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("id_producto"));
oProd.Id_prodprese = rdr.IsDBNull(rdr.GetOrdinal("id_prodprese")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("id_prodprese"));
oProd.Ds_prodprese = rdr.IsDBNull(rdr.GetOrdinal("ds_prodprese")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("ds_prodprese"));
oProd.Nu_uniprese = rdr.IsDBNull(rdr.GetOrdinal("nu_uniprese")) ? 0 : rdr.GetInt16(rdr.GetOrdinal("nu_uniprese"));
oProd.Nu_umprese = rdr.IsDBNull(rdr.GetOrdinal("nu_umprese")) ? 0 : rdr.GetInt16(rdr.GetOrdinal("nu_umprese"));
oProd.Qt_pesoneto = rdr.IsDBNull(rdr.GetOrdinal("qt_pesoneto")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("qt_pesoneto"));
oProd.Qt_pesobruto = rdr.IsDBNull(rdr.GetOrdinal("qt_pesobruto")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("qt_pesobruto"));
oProd.Mt_precio = rdr.IsDBNull(rdr.GetOrdinal("mt_precio")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("mt_precio"));
//oProd.St_anulado = rdr.IsDBNull(rdr.GetOrdinal("st_anulado")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("st_anulado"));
return oProd;
}
示例2: GetInt16
public static short GetInt16(IDataReader dr, string columnName)
{
int ordinal = dr.GetOrdinal(columnName);
bool isDbNull = dr.IsDBNull(ordinal);
return isDbNull ? ((short)0) : dr.GetInt16(ordinal);
}
示例3: getInt16
protected static int getInt16(IDataReader dataReader, int column)
{
if (!dataReader.IsDBNull(column))
return dataReader.GetInt16(column);
return 0;
}
示例4: LoadQuizzes
private IList<Subscriptions> LoadQuizzes(IDataReader reader)
{
IList<Subscriptions> quizzes = new List<Subscriptions>();
while (reader.Read())
{
Subscriptions quiz = new Subscriptions(reader.GetString(reader.GetOrdinal("QuizTopic")), reader.GetString(reader.GetOrdinal("Period")), reader.IsDBNull(reader.GetOrdinal("PeriodYear")) ? null : (short?)reader.GetInt16(reader.GetOrdinal("PeriodYear")));
quizzes.Add(quiz);
_IdsByHashCode.Add(quiz.GetHashCode(), reader.GetInt32(reader.GetOrdinal("QuizDefinitionID")));
}
return quizzes;
}
示例5: UserStatusAttachment
public UserStatusAttachment(IDataReader reader)
: this()
{
AttachmentId = reader.GetInt64(0);
UserId = reader.GetInt64(1);
StatusKey = reader.GetString(2);
PreviewImageUrl = reader.GetString(3);
PreviewAltText = reader.GetString(4);
TargetUrl = reader.GetString(5);
MediaType = reader.GetInt16(6);
DateCreated = reader.ReadDateTime(7);
}
示例6: FillTemplateFromReader
internal static Template FillTemplateFromReader(IDataReader reader)
{
var template = new Template();
if (reader != null && !reader.IsClosed)
{
DataTable dt = reader.GetSchemaTable();
if (dt.Select("ColumnName='" + "CommandId" + "'").Length > 0)
if (!reader.IsDBNull(reader.GetOrdinal("CommandId")))
template.TemplateId = reader.GetInt16(reader.GetOrdinal("CommandId"));
if (dt.Select("ColumnName='" + "Name" + "'").Length > 0)
if (!reader.IsDBNull(reader.GetOrdinal("Name")))
template.Name = reader.GetString(reader.GetOrdinal("Name"));
if (dt.Select("ColumnName='" + "Description" + "'").Length > 0)
if (!reader.IsDBNull(reader.GetOrdinal("Description")))
template.Description = reader.GetString(reader.GetOrdinal("Description"));
if (dt.Select("ColumnName='" + "CannedCommand" + "'").Length > 0)
if (!reader.IsDBNull(reader.GetOrdinal("CannedCommand")))
template.CannedCommand = reader.GetByte(reader.GetOrdinal("CannedCommand"));
if (dt.Select("ColumnName='" + "AppName" + "'").Length > 0)
if (!reader.IsDBNull(reader.GetOrdinal("AppName")))
template.AppName = reader.GetString(reader.GetOrdinal("AppName"));
if (dt.Select("ColumnName='" + "Params" + "'").Length > 0)
if (!reader.IsDBNull(reader.GetOrdinal("Params")))
template.Params = reader.GetString(reader.GetOrdinal("Params"));
if (dt.Select("ColumnName='" + "UseCommandShell" + "'").Length > 0)
if (!reader.IsDBNull(reader.GetOrdinal("UseCommandShell")))
template.UseCommandShell = reader.GetByte(reader.GetOrdinal("UseCommandShell"));
if (dt.Select("ColumnName='" + "TimeoutDurationSecs" + "'").Length > 0)
if (!reader.IsDBNull(reader.GetOrdinal("TimeoutDurationSecs")))
template.TimeoutDurationSecs = reader.GetInt16(reader.GetOrdinal("TimeoutDurationSecs"));
if (dt.Select("ColumnName='" + "UserId" + "'").Length > 0)
if (!reader.IsDBNull(reader.GetOrdinal("UserId")))
template.UserId = reader.GetInt16(reader.GetOrdinal("UserId"));
if (dt.Select("ColumnName='" + "WaitInterval" + "'").Length > 0)
if (!reader.IsDBNull(reader.GetOrdinal("WaitInterval")))
template.WaitInterval = reader.GetInt16(reader.GetOrdinal("WaitInterval"));
if (dt.Select("ColumnName='" + "InvokeCategory" + "'").Length > 0)
if (!reader.IsDBNull(reader.GetOrdinal("InvokeCategory")))
template.InvokeCategory = reader.GetString(reader.GetOrdinal("InvokeCategory"));
if (dt.Select("ColumnName='" + "InvokeItemName" + "'").Length > 0)
if (!reader.IsDBNull(reader.GetOrdinal("InvokeItemName")))
template.InvokeItemName = reader.GetString(reader.GetOrdinal("InvokeItemName"));
if (dt.Select("ColumnName='" + "CommandResultTestPatternText" + "'").Length > 0)
if (!reader.IsDBNull(reader.GetOrdinal("CommandResultTestPatternText")))
template.CommandResultTestPatternText = reader.GetString(reader.GetOrdinal("CommandResultTestPatternText"));
if (dt.Select("ColumnName='" + "CommandResultTestPatternType" + "'").Length > 0)
if (!reader.IsDBNull(reader.GetOrdinal("CommandResultTestPatternType")))
template.CommandResultTestPatternType = reader.GetInt16(reader.GetOrdinal("CommandResultTestPatternType"));
if (dt.Select("ColumnName='" + "CommandMenuGroupId" + "'").Length > 0)
if (!reader.IsDBNull(reader.GetOrdinal("CommandMenuGroupId")))
template.CommandMenuGroupId = reader.GetInt16(reader.GetOrdinal("CommandMenuGroupId"));
}
return template;
}
示例7: getRealValue
private static object getRealValue(IDataReader datareader, int ordinal, Type t)
{
if (t == typeof(Int16)) return !datareader.IsDBNull(ordinal) ? (object)datareader.GetInt16(ordinal) : null;
if (t == typeof(Int32)) return !datareader.IsDBNull(ordinal) ? (object)datareader.GetInt32(ordinal) : null;
if (t == typeof(Int64)) return !datareader.IsDBNull(ordinal) ? (object)datareader.GetInt32(ordinal) : null;
if (t == typeof(Byte[]))
{
if (datareader.IsDBNull(ordinal)) return null;
int bufferSize = 1024;
int startIndex = 0;
byte[] outbyte = new byte[bufferSize];
ByteBuilder bb = new ByteBuilder();
long retval = datareader.GetBytes(ordinal, startIndex, outbyte, 0, bufferSize);
while (retval == bufferSize)
{
bb.Append(outbyte);
startIndex += bufferSize;
retval = datareader.GetBytes(ordinal, startIndex, outbyte, 0, bufferSize);
}
if (retval > 0)
bb.Append(outbyte);
return bb.GetBytes();
}
if (t == typeof(String)) return !datareader.IsDBNull(ordinal) ? datareader.GetString(ordinal) : null;
if (t == typeof(DateTime)) return !datareader.IsDBNull(ordinal) ? (object)datareader.GetDateTime(ordinal) : null;
if (t == typeof(Boolean)) return !datareader.IsDBNull(ordinal) ? (object)datareader.GetBoolean(ordinal) : null;
if (t == typeof(Double)) return !datareader.IsDBNull(ordinal) ? (object)datareader.GetDouble(ordinal) : null;
if (t == typeof(Single)) return !datareader.IsDBNull(ordinal) ? (object)datareader.GetFloat(ordinal) : null;
if (t == typeof(Guid)) return !datareader.IsDBNull(ordinal) ? (object)datareader.GetGuid(ordinal) : null;
if (t == typeof(Decimal)) return !datareader.IsDBNull(ordinal) ? (object)datareader.GetDecimal(ordinal) : null;
if (t == typeof(Byte)) return !datareader.IsDBNull(ordinal) ? (object)datareader.GetByte(ordinal) : null;
return null;
}
示例8: NullSafeGet
public object NullSafeGet(IDataReader rs, string[] names, object owner)
{
object sbyte1 = null;
int ord = rs.GetOrdinal(names[0]);
if (!rs.IsDBNull(ord))
{
object tempO = rs.GetValue(ord);
if (tempO is Byte)
{
sbyte1 = Convert.ToSByte(((byte)tempO));
}
else
{
short temp = rs.GetInt16(ord);
sbyte1 = Convert.ToSByte(temp);
}
}
return sbyte1;
}
示例9: fetchFriendList
public ArrayList fetchFriendList(UInt32 charId)
{
ArrayList friends = new ArrayList();
string query = "SELECT C.handle, C.is_online, B.friendId FROM characters C, buddylist B WHERE B.charId = '" + charId + "' AND B.friendId=C.charId ";
queryExecuter = conn.CreateCommand();
queryExecuter.CommandText = query;
dr = queryExecuter.ExecuteReader();
while (dr.Read())
{
Hashtable data = new Hashtable();
data.Add("handle", dr.GetString(0));
data.Add("online", dr.GetInt16(1));
friends.Add(data);
}
dr.Close();
// ToDo: Write query
// ToDo2: add online flag to characters and handle this on "connect" and "disconnect"
return friends;
}
示例10: GetNullableShortFromReader
static int? GetNullableShortFromReader(IDataReader reader, int index)
{
if (reader.IsDBNull(index)) return null;
return reader.GetInt16(index);
}
示例11: mCargarTJ
private static ETejeduria mCargarTJ(IDataReader rdr)
{
ETejeduria oTJ = new ETejeduria();
oTJ.Id_producto = rdr.IsDBNull(rdr.GetOrdinal("id_producto")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("id_producto"));
oTJ.ds_producto = rdr.IsDBNull(rdr.GetOrdinal("ds_producto")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("ds_producto"));
oTJ.Nu_correficha = rdr.IsDBNull(rdr.GetOrdinal("nu_correficha")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("nu_correficha"));
oTJ.Id_clipro = rdr.IsDBNull(rdr.GetOrdinal("id_clipro")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("id_clipro"));
oTJ.ds_razonSoc = rdr.IsDBNull(rdr.GetOrdinal("ds_raznombre")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("ds_raznombre"));
oTJ.Fe_registro = rdr.IsDBNull(rdr.GetOrdinal("fe_registro")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("fe_registro"));
oTJ.Nu_refmuestra = rdr.IsDBNull(rdr.GetOrdinal("nu_refmuestra")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("nu_refmuestra"));
oTJ.Nu_tf = rdr.IsDBNull(rdr.GetOrdinal("nu_tf")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("nu_tf"));
oTJ.Nu_gt = rdr.IsDBNull(rdr.GetOrdinal("nu_gt")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("nu_gt"));
oTJ.Nu_tfref = rdr.IsDBNull(rdr.GetOrdinal("nu_tfref")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("nu_tfref"));
oTJ.Id_vtipmcdo = rdr.IsDBNull(rdr.GetOrdinal("id_vtipmcdo")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("id_vtipmcdo"));
oTJ.Nu_regula = rdr.IsDBNull(rdr.GetOrdinal("nu_regula")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("nu_regula"));
oTJ.Id_vdestino = rdr.IsDBNull(rdr.GetOrdinal("id_vdestino")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("id_vdestino"));
oTJ.Id_vtipancru = rdr.IsDBNull(rdr.GetOrdinal("id_vtipancru")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("id_vtipancru"));
oTJ.Qt_anchcrudo = rdr.IsDBNull(rdr.GetOrdinal("qt_anchcrudo")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("qt_anchcrudo"));
oTJ.Qt_denscrudo = rdr.IsDBNull(rdr.GetOrdinal("qt_denscrudo")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("qt_denscrudo"));
oTJ.Qt_rendcrudo = rdr.IsDBNull(rdr.GetOrdinal("qt_rendcrudo")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("qt_rendcrudo"));
oTJ.Qt_anchacaba = rdr.IsDBNull(rdr.GetOrdinal("qt_anchacaba")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("qt_anchacaba"));
oTJ.Qt_densacaba = rdr.IsDBNull(rdr.GetOrdinal("qt_densacaba")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("qt_densacaba"));
oTJ.Qt_rendacaba = rdr.IsDBNull(rdr.GetOrdinal("qt_rendacaba")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("qt_rendacaba"));
oTJ.Id_maqtenido = rdr.IsDBNull(rdr.GetOrdinal("id_maqtenido")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("id_maqtenido"));
oTJ.Nu_porencla = rdr.IsDBNull(rdr.GetOrdinal("nu_porencla")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("nu_porencla"));
oTJ.Nu_porencan = rdr.IsDBNull(rdr.GetOrdinal("nu_porencan")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("nu_porencan"));
oTJ.Ds_observa = rdr.IsDBNull(rdr.GetOrdinal("ds_observa")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("ds_observa"));
oTJ.Nu_porrev = rdr.IsDBNull(rdr.GetOrdinal("nu_porrev")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("nu_porrev"));
oTJ.Nu_gradosrev = rdr.IsDBNull(rdr.GetOrdinal("nu_gradosrev")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("nu_gradosrev"));
oTJ.Nu_pormerma = rdr.IsDBNull(rdr.GetOrdinal("nu_pormerma")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("nu_pormerma"));
oTJ.Mt_costtenido = rdr.IsDBNull(rdr.GetOrdinal("mt_costtenido")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("mt_costtenido"));
oTJ.Mt_totconsumo = rdr.IsDBNull(rdr.GetOrdinal("mt_totconsumo")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("mt_totconsumo"));
oTJ.Id_ptmaq = rdr.IsDBNull(rdr.GetOrdinal("id_ptmaq")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("id_ptmaq"));
oTJ.Nu_ptdiame = rdr.IsDBNull(rdr.GetOrdinal("nu_ptdiame")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("nu_ptdiame"));
oTJ.Nu_ptgalga = rdr.IsDBNull(rdr.GetOrdinal("nu_ptgalga")) ? 0 : rdr.GetInt16(rdr.GetOrdinal("nu_ptgalga"));
oTJ.Nu_ptsistrab = rdr.IsDBNull(rdr.GetOrdinal("nu_ptsistrab")) ? 0 : rdr.GetInt16(rdr.GetOrdinal("nu_ptsistrab"));
oTJ.Nu_ptsisanul = rdr.IsDBNull(rdr.GetOrdinal("nu_ptsisanul")) ? 0 : rdr.GetInt16(rdr.GetOrdinal("nu_ptsisanul"));
oTJ.Nu_ptrpm = rdr.IsDBNull(rdr.GetOrdinal("nu_ptrpm")) ? 0 : rdr.GetInt16(rdr.GetOrdinal("nu_ptrpm"));
oTJ.Qt_ptpeso = rdr.IsDBNull(rdr.GetOrdinal("qt_ptpeso")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("qt_ptpeso"));
oTJ.Ds_obstejido = rdr.IsDBNull(rdr.GetOrdinal("ds_obstejido")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("ds_obstejido"));
oTJ.Ds_evadeftj = rdr.IsDBNull(rdr.GetOrdinal("ds_evadeftj")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("ds_evadeftj"));
oTJ.nu_platina = rdr.IsDBNull(rdr.GetOrdinal("nu_platina")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("nu_platina"));
oTJ.qt_anchdatreqacaba = rdr.IsDBNull(rdr.GetOrdinal("qt_anchdatreqacaba")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("qt_anchdatreqacaba"));
oTJ.qt_densdatreqacaba = rdr.IsDBNull(rdr.GetOrdinal("qt_densdatreqacaba")) ? 0 : rdr.GetDecimal(rdr.GetOrdinal("qt_densdatreqacaba"));
oTJ.Id_Color = rdr.IsDBNull(rdr.GetOrdinal("id_color")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("id_color"));
oTJ.ds_Color = rdr.IsDBNull(rdr.GetOrdinal("dsColor")) ? String.Empty : rdr.GetString(rdr.GetOrdinal("dsColor"));
return oTJ;
}
示例12: GetIntValue
public static int? GetIntValue(
IDataReader rs,
string fieldName)
{
int col = rs.GetOrdinal(fieldName);
// GetInt32 only works when the field has a data type of "int" in SQL Server.
// If the field is a "smallint", an InvalidCastException will be thrown and GetIn16
// will be used as a result.
// Question: what if it is a "tinyint"? Or this method will only be used for "int" and "smallint"?
try {
return rs.IsDBNull(col) ? (int?)null : (int)rs.GetInt32(col);
} catch (InvalidCastException) {
return rs.IsDBNull(col) ? (int?)null : (int)rs.GetInt16(col);
}
}
示例13: GetPeriod
private Period GetPeriod(IDataReader reader)
{
return new Period(
reader.GetString("Period"),
reader.GetInt16("PeriodYear") ?? (short)DateTime.Today.Year,
reader.GetDateTime("FirstDate") ?? DateTime.Today,
reader.GetDateTime("LastDate") ?? DateTime.Today);
}
示例14: updateSourceHlForObjectTracking
public void updateSourceHlForObjectTracking(UInt16 sourceDistrict, UInt16 sourceHl, UInt32 lastObjectId)
{
string sqlQuery = "SELECT id,HardlineId, DistrictId, objectId FROM data_hardlines WHERE DistrictId = '" + sourceDistrict.ToString() + "' AND HardlineId = '" + sourceHl.ToString() + "' LIMIT 1";
queryExecuter = conn.CreateCommand();
queryExecuter.CommandText = sqlQuery;
dr = queryExecuter.ExecuteReader();
UInt16 theId = 0;
UInt16 hardlineId = 0;
UInt16 districtId = 0;
UInt32 objectId = 0;
while (dr.Read())
{
theId = (UInt16)dr.GetInt16(0);
hardlineId = (UInt16)dr.GetInt16(1);
districtId = (UInt16)dr.GetInt16(2);
objectId = (UInt32)dr.GetInt32(3);
}
dr.Close();
if (objectId == 0 || objectId != lastObjectId)
{
string updateQuery = "UPDATE data_hardlines SET objectId = '" + lastObjectId.ToString() + "' WHERE id = '" + theId.ToString() + "' LIMIT 1";
queryExecuter = conn.CreateCommand();
queryExecuter.CommandText = updateQuery;
queryExecuter.ExecuteNonQuery();
Output.WriteLine("[WORLD DB] UPDATE Hardline " + hardlineId.ToString() + " in District " + districtId.ToString() + " with Object ID : "+lastObjectId.ToString());
}
}
示例15: GetPeriod
private Period GetPeriod(IDataReader reader)
{
return new Period(reader.GetString(reader.GetOrdinal("Period")), reader.GetInt16(reader.GetOrdinal("PeriodYear")));
}