本文整理汇总了C#中System.Data.SqlClient.SqlDataReader.GetInt16方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDataReader.GetInt16方法的具体用法?C# SqlDataReader.GetInt16怎么用?C# SqlDataReader.GetInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlDataReader
的用法示例。
在下文中一共展示了SqlDataReader.GetInt16方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SupplierListInfo
public SupplierListInfo(SqlDataReader reader)
{
//[Id], Guid,Email,[Name],CompanyName, Address, PhoneNumber, Status,FoundedYear,AllowMatch,Balance,GeneralScore,Priority
id = reader.GetInt32(0);
guid = reader.GetString(1);
email = reader.GetString(2);
name = reader.IsDBNull(3) ? "" : reader.GetString(3);
companyName = reader.IsDBNull(4) ? "" : reader.GetString(4);
address = reader.IsDBNull(5) ? "" : reader.GetString(5);
phoneNumber = reader.IsDBNull(6) ? "" : reader.GetString(6);
status = (CompanyStatus)(reader.GetInt16(7));
foundedYear = reader.GetInt16(8);
regDate = reader.GetDateTime(9);
allowMatch = reader.GetString(10) == "1";
balance = Convert.ToSingle(reader.GetValue(11));
generalScore = Convert.ToSingle(reader.GetValue(12));
priority = reader.GetInt32(13);
}
示例2: GetProducts
private List<Product> GetProducts(SqlDataReader reader)
{
var products = new List<Product>();
while (reader.Read())
{
products.Add(new Product
{
ProductName = reader.GetString(1),
UnitsInStock = reader.GetInt16(6)
});
}
return (products);
}
示例3: CopyCategoryToBO
public static CategoryInfo CopyCategoryToBO(SqlDataReader rdr)
{
//CAT_ID, CAT_NAME, CAT_STATUS, CAT_MODERATION, CAT_SUBSCRIPTION, CAT_ORDER
CategoryInfo category = new CategoryInfo
{
Id = rdr.GetInt32(0),
Name = rdr.SafeGetString(1),
Status = rdr.GetInt16(2),
ModerationLevel = rdr.SafeGetInt32(3),
SubscriptionLevel = rdr.SafeGetInt32(4),
Order = rdr.GetInt32(5)
};
return category;
}
示例4: CopyForumToBO
public static ForumInfo CopyForumToBO(SqlDataReader rdr)
{
//"F.FORUM_ID,F.CAT_ID,F.F_STATUS,F.F_SUBJECT,F.F_URL,F.F_TOPICS" +
//",F.F_COUNT,F.F_LAST_POST,F.F_PRIVATEFORUMS,F.F_TYPE,F.F_LAST_POST_AUTHOR,F.F_A_TOPICS,F.F_A_COUNT,F.F_MODERATION" +
//",F.F_SUBSCRIPTION,F.F_ORDER, F.F_COUNT_M_POSTS,F.F_LAST_POST_TOPIC_ID,F.F_LAST_POST_REPLY_ID,F.F_POLLS,F.F_DESCRIPTION" +
//",F.F_L_ARCHIVE,F.F_ARCHIVE_SCHED,T.T_SUBJECT,M.M_NAME ";
ForumInfo forum = new ForumInfo
{
Id = rdr.GetInt32(0),
CatId = rdr.GetInt32(1),
Status = rdr.GetInt16(2),
Subject = rdr.SafeGetString(3),
Url = rdr.SafeGetString(4),
TopicCount = rdr.GetInt32(5),
PostCount = rdr.GetInt32(6),
LastPostDate = rdr.GetSnitzDate(7),
AuthType = rdr.SafeGetInt32(8),
Type = rdr.GetInt16(9),
LastPostAuthorId = rdr.SafeGetInt32(10),
ArchivedTopicCount = rdr.SafeGetInt32(11),
ArchivedPostCount = rdr.SafeGetInt32(12),
ModerationLevel = rdr.SafeGetInt32(13),
SubscriptionLevel = rdr.SafeGetInt32(14),
Order = rdr.GetInt32(15),
UpdatePostCount = rdr.GetInt16(16) == 1,
LastPostTopicId = rdr.SafeGetInt32(17),
LastPostReplyId = rdr.SafeGetInt32(18),
AllowPolls = rdr.GetInt32(19) == 1,
Description = rdr.SafeGetString(20),
LastArchived = rdr.GetSnitzDate(21),
ArchiveFrequency = rdr.SafeGetInt32(22),
LastPostSubject = rdr.SafeGetString(23),
LastPostAuthorName = rdr.SafeGetString(24)
};
return forum;
}
示例5: build_sql_job_metric_from_reader
SqlJobMetrics build_sql_job_metric_from_reader(SqlDataReader reader)
{
var metric = new SqlJobMetrics();
metric.job_name = reader.GetString(0);
metric.message = reader.GetString(1);
var job_outcome_key = reader.GetByte(2);
metric.job_status = get_job_outcome_from_key(job_outcome_key);
metric.last_run = reader.GetDateTime(3);
metric.job_step = reader.GetInt16(4);
return metric;
}
示例6: CopyForumToBO
public static ForumInfo CopyForumToBO(SqlDataReader rdr)
{
ForumInfo forum = new ForumInfo
{
Id = rdr.GetInt32(0),
CatId = rdr.GetInt32(1),
Status = rdr.GetInt16(2),
Subject = rdr.SafeGetString(3),
Url = rdr.SafeGetString(4),
TopicCount = rdr.GetInt32(5),
PostCount = rdr.GetInt32(6),
LastPostDate = rdr.SafeGetString(7).ToDateTime(),
AuthType = rdr.SafeGetInt32(8),
Type = rdr.GetInt16(9),
LastPostAuthorId = rdr.SafeGetInt32(10),
ArchivedTopicCount = rdr.SafeGetInt32(11),
ArchivedPostCount = rdr.SafeGetInt32(12),
ModerationLevel = rdr.SafeGetInt32(13),
SubscriptionLevel = rdr.SafeGetInt32(14),
Order = rdr.GetInt32(15),
UpdatePostCount = rdr.GetInt16(16) == 1,
LastPostTopicId = rdr.SafeGetInt32(17),
LastPostReplyId = rdr.SafeGetInt32(18),
AllowPolls = rdr.GetInt32(19) == 1,
Description = rdr.SafeGetString(20),
LastPostSubject = rdr.SafeGetString(21),
LastPostAuthorName = rdr.SafeGetString(22)
};
//if (forum.LastPostAuthorId != null)
//{
// var author = new PostAuthor().GetAuthor(forum.LastPostAuthorId.Value);
// forum.LastPostAuthor = author;
//}
return forum;
}
示例7: MakeViewProductoObjetivo
/// <summary>
/// Creates a new instance of the ViewProductoObjetivo class and populates it with data from the specified SqlDataReader.
/// </summary>
private static ViewProductoObjetivoInfo MakeViewProductoObjetivo(SqlDataReader dataReader)
{
ViewProductoObjetivoInfo viewProductoObjetivo = new ViewProductoObjetivoInfo();
if (dataReader.IsDBNull(Cod_Producto) == false)
viewProductoObjetivo.Cod_Producto = dataReader.GetInt32(Cod_Producto);
if (dataReader.IsDBNull(Cod_Trilogia) == false)
viewProductoObjetivo.Cod_Trilogia = dataReader.GetInt32(Cod_Trilogia);
if (dataReader.IsDBNull(Producto) == false)
viewProductoObjetivo.Producto = dataReader.GetString(Producto);
if (dataReader.IsDBNull(Cantidad) == false)
viewProductoObjetivo.Cantidad = dataReader.GetInt16(Cantidad);
return viewProductoObjetivo;
}
示例8: CopySearchResultToBO
public static SearchResult CopySearchResultToBO(SqlDataReader rdr, ref int rowcount)
{
SearchResult result = new SearchResult()
{
CategoryStatus = rdr.GetInt16(1),
CategorySubscriptionLevel = rdr.GetInt32(2),
CategoryTitle = rdr.SafeGetString(3),
ForumSubject = rdr.SafeGetString(4),
ForumSubscriptionLevel = rdr.GetInt32(5),
ForumStatus = rdr.GetInt16(6),
ForumAccessType = rdr.GetInt32(7),
ForumPassword = rdr.SafeGetString(8),
CatId = rdr.GetInt32(9),
ForumId = rdr.GetInt32(10),
Id = rdr.GetInt32(11),
AuthorId = rdr.GetInt32(12),
Subject = rdr.SafeGetString(13),
Status = rdr.GetInt16(14),
LastPostDate = rdr.GetSnitzDate(15),
LastPostAuthorId = rdr.SafeGetInt32(16),
LastReplyId = rdr.SafeGetInt32(17),
ReplyCount = rdr.GetInt32(18),
UnModeratedReplies = rdr.GetInt32(19),
Views = rdr.GetInt32(20),
AuthorName = rdr.SafeGetString(22),
LastPostAuthorName = rdr.SafeGetString(23)
};
rowcount = rdr.GetInt32(24);
return result;
}
示例9: ReportBuilder
//.........这里部分代码省略.........
PdfReports.AddText2Table(table, drLandDesc.GetString(drLandDesc.GetOrdinal("cntg_farm_number")), normalFont);
PdfReports.AddText2Table(table, "Tract No: ", labelFont);
PdfReports.AddText2Table(table, drLandDesc.GetString(drLandDesc.GetOrdinal("cntg_tract_number")), normalFont);
PdfReports.AddText2Table(table, "Field No: ", labelFont);
PdfReports.AddText2Table(table, drLandDesc.GetString(drLandDesc.GetOrdinal("cntg_field_number")), normalFont);
PdfReports.AddText2Table(table, "1/4 Field: ", labelFont);
PdfReports.AddText2Table(table, drLandDesc.GetString(drLandDesc.GetOrdinal("cntg_quarter_field")), normalFont, 7);
// *** ROW 6 ***
PdfReports.AddText2Table(table, "Description", labelFont);
PdfReports.AddText2Table(table, drLandDesc.GetString(drLandDesc.GetOrdinal("cntg_description")), normalFont, 7);
PdfReports.AddTableNoSplit(document, pgEvent, table);
}
// ======================================================
// Planting Block
// ======================================================
phrase = new Phrase("\nVariety: ", labelFont);
para = new Paragraph();
para.Add(phrase);
tmp = dr.GetString(dr.GetOrdinal("fld_seed_variety"));
if (tmp.Length == 0) {
tmpLayout = new float[] { 540F };
table = PdfReports.CreateTable(tmpLayout, 0);
// No seed found in Field record, so list the possible seed options
// based on state information
string factoryNumber = dr.GetInt16(dr.GetOrdinal("fld_factory_no")).ToString();
if (factoryNumber.Length == 0) {
PdfReports.AddText2Table(table, para);
// No state in Field record, list all possible seed options
para = GetSeedsAsText(agronomy, "6", labelFont, normalFont, true);
cell = new iTextSharp.text.pdf.PdfPCell(para);
cell.BorderWidth = 1;
table.AddCell(cell);
phrase = new Phrase("\n", labelFont);
PdfReports.AddText2Table(table, phrase);
para = GetSeedsAsText(agronomy, "2", labelFont, normalFont, true);
cell = new iTextSharp.text.pdf.PdfPCell(para);
cell.BorderWidth = 1;
table.AddCell(cell);
} else {
PdfReports.AddText2Table(table, para);
para = GetSeedsAsText(agronomy, factoryNumber, labelFont, normalFont, true);
cell = new iTextSharp.text.pdf.PdfPCell(para);
cell.BorderWidth = 1;
table.AddCell(cell);
}
示例10: CopyReplyToBO
public static ReplyInfo CopyReplyToBO(SqlDataReader rdr)
{
ReplyInfo reply = new ReplyInfo
{
Id = rdr.GetInt32(0),
CatId = rdr.GetInt32(1),
ForumId = rdr.GetInt32(2),
TopicId = rdr.GetInt32(3),
AuthorId = rdr.GetInt32(4),
Date = rdr.GetString(5).ToDateTime().Value,
PosterIp = rdr.SafeGetString(6),
Status = rdr.GetInt16(7),
LastEditDate = rdr.SafeGetString(8).ToDateTime(),
LastEditedById = rdr.SafeGetInt32(9),
UseSignatures = rdr.GetInt16(10) == 1,
Message = rdr.SafeGetString(11)
};
if (rdr.FieldCount > 12)
{
reply.AuthorName = rdr.SafeGetString(12);
reply.EditorName = rdr.SafeGetString(13);
reply.AuthorViewSig = rdr.GetInt16(14) == 1;
reply.AuthorSignature = rdr.SafeGetString(15);
}
return reply;
}
示例11: GetSmallInt
public static int GetSmallInt(string pColName,SqlDataReader pReader)
{
return pReader.GetInt16(pReader.GetOrdinal(pColName));
}
示例12: PengecekField
// Jika tidak menggunakan constructor
// hapus pada baris yg di comment
// ====================================
// | Alt + Insert untuk meng-generate |
// | construktor dari class yg dibuat |
// ====================================
public string PengecekField(SqlDataReader hasilPembaca, byte kolom)
{
string hasil = "";
if (hasilPembaca.IsDBNull(kolom))
{
if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.Byte")
hasil = "0";
else if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.Boolean")
hasil = "false";
else if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.Int32")
hasil = "0";
else if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.Int16")
hasil = "0";
else if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.String")
hasil = "";
else if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.Decimal")
hasil = "0";
else if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.Int64")
hasil = "0";
else if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.DateTime")
hasil = "0";
else
{
MessageBox.Show(Resources.CAlat_PengecekField_Tipe_data_tidak_di_kenali, Resources.CAlat_PengecekField_Infomasi, MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
else
{
if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.Byte")
hasil = hasilPembaca.GetByte(kolom).ToString().Trim();
else if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.Boolean")
hasil = hasilPembaca.GetBoolean(kolom).ToString().Trim();
else if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.Int32")
hasil = hasilPembaca.GetInt32(kolom).ToString().Trim();
else if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.Int16")
hasil = hasilPembaca.GetInt16(kolom).ToString().Trim();
else if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.String")
hasil = hasilPembaca.GetString(kolom).ToString().Trim();
else if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.Decimal")
hasil = hasilPembaca.GetDecimal(kolom).ToString().Trim();
else if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.Int64")
hasil = hasilPembaca.GetInt64(kolom).ToString().Trim();
else if (hasilPembaca.GetFieldType(kolom).ToString().Trim() == "System.DateTime")
hasil = string.Format("{0:MM/dd/yyyy}", hasilPembaca.GetDateTime(kolom));
else
{
MessageBox.Show(Resources.CAlat_PengecekField_Tipe_data_tidak_di_kenali, Resources.CAlat_PengecekField_Infomasi, MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
return hasil;
}
示例13: DataReader_To_Simple_Result_List2
private static List<iSearch_Title_Result> DataReader_To_Simple_Result_List2(SqlDataReader Reader, List<string> Metadata_Field_Names)
{
// Create return list
List<iSearch_Title_Result> returnValue = new List<iSearch_Title_Result>();
// Create some lists used during the construction
Dictionary<int, Database_Title_Result> titleLookupByRowNumber = new Dictionary<int, Database_Title_Result>();
Dictionary<int, Database_Item_Result> itemLookupByItemID = new Dictionary<int, Database_Item_Result>();
Dictionary<int, int> rowNumberLookupByItemID = new Dictionary<int, int>();
// May have not values returned
if (Reader.FieldCount < 5)
return null;
// Get all the main title values first
int minimumRownumber = -1;
while (Reader.Read())
{
// Create new database title object for this
Database_Title_Result result = new Database_Title_Result
{
RowNumber = Reader.GetInt32(0),
BibID = Reader.GetString(1),
GroupTitle = Reader.GetString(2),
OPAC_Number = Reader.GetInt32(3),
OCLC_Number = Reader.GetInt64(4),
GroupThumbnail = Reader.GetString(5),
MaterialType = Reader.GetString(6),
Primary_Identifier_Type = Reader.GetString(7),
Primary_Identifier = Reader.GetString(8)
};
titleLookupByRowNumber.Add(result.RowNumber, result);
if (minimumRownumber == -1)
{
minimumRownumber = result.RowNumber;
}
}
// Move to the item system-required information table
Reader.NextResult();
// If there were no titles, then there are no results
if (titleLookupByRowNumber.Count == 0)
return returnValue;
// Step through all the item rows, build the item, and add to the title
Database_Title_Result titleResult = titleLookupByRowNumber[minimumRownumber];
returnValue.Add(titleResult);
int lastRownumber = titleResult.RowNumber;
while (Reader.Read())
{
// Ensure this is the right title for this item
int thisRownumber = Reader.GetInt32(0);
if (thisRownumber != lastRownumber)
{
titleResult = titleLookupByRowNumber[thisRownumber];
lastRownumber = thisRownumber;
// Add this title to the list
returnValue.Add(titleResult);
}
// Create new database item object for this
Database_Item_Result result = new Database_Item_Result
{
ItemID = Reader.GetInt32(1),
VID = Reader.GetString(2),
Title = Reader.GetString(3),
IP_Restriction_Mask = Reader.GetInt16(4),
MainThumbnail = Reader.GetString(5),
Level1_Index = (short)Reader.GetInt32(6),
Level1_Text = Reader.GetString(7),
Level2_Index = (short)Reader.GetInt32(8),
Level2_Text = Reader.GetString(9),
Level3_Index = (short)Reader.GetInt32(10),
Level3_Text = Reader.GetString(11),
PubDate = Reader.GetString(12),
PageCount = Reader.GetInt32(13),
Link = Reader.GetString(14),
Spatial_KML = Reader.GetString(15),
COinS_OpenURL = Reader.GetString(16)
};
// Save to the hash lookup for adding display metadata
itemLookupByItemID[result.ItemID] = result;
rowNumberLookupByItemID[result.ItemID] = thisRownumber;
// Add this to the title object
titleResult.Add_Item_Result(result);
}
// Move to the item aggregation-configured display information table
Reader.NextResult();
// Set some values for checking for uniformity of values
const int ITEMS_TO_CHECK_IN_EACH_TITLE = 20;
bool first_item_analyzed = true;
List<bool> checking_fields = new List<bool>();
//.........这里部分代码省略.........
示例14: getFieldValue
public static short getFieldValue(SqlDataReader dr, int ind, short def)
{
short val = def;
if (!dr.IsDBNull(ind))
{
System.TypeCode tp = System.Type.GetTypeCode(dr.GetFieldType(ind));
System.TypeCode typeCode = tp;
switch (typeCode)
{
case System.TypeCode.Boolean:
val = (dr.GetBoolean(ind) ? System.Convert.ToInt16(1) : System.Convert.ToInt16(0));
break;
case System.TypeCode.Char:
case System.TypeCode.SByte:
case System.TypeCode.UInt16:
break;
case System.TypeCode.Byte:
val = System.Convert.ToInt16(dr.GetByte(ind));
break;
case System.TypeCode.Int16:
val = dr.GetInt16(ind);
break;
case System.TypeCode.Int32:
val = System.Convert.ToInt16(dr.GetInt32(ind));
break;
default:
if (typeCode == System.TypeCode.Decimal)
{
val = System.Convert.ToInt16(dr.GetDecimal(ind));
}
break;
}
}
return val;
}
示例15: PopulateEntity
protected static void PopulateEntity(SqlDataReader reader, ServerEntity entity, Dictionary<string, PropertyInfo> propMap)
{
for (int i = 0; i < reader.FieldCount; i++)
{
String columnName = reader.GetName(i);
// Special case for when we select a range of values with an EntityBroker, just ignore
if (columnName.Equals("RowNum"))
continue;
if (columnName.Equals("GUID"))
{
Guid uid = reader.GetGuid(i);
entity.SetKey(new ServerEntityKey(entity.Name, uid));
continue;
}
if (columnName.Equals(entity.Name) && columnName.Contains("Enum"))
columnName = "Enum";
PropertyInfo prop;
if (!propMap.TryGetValue(columnName, out prop))
throw new EntityNotFoundException("Unable to match column to property: " + columnName, null);
if (columnName.Contains("GUID"))
columnName = columnName.Replace("GUID", "Key");
if (reader.IsDBNull(i))
{
prop.SetValue(entity, null, null);
continue;
}
Type propType = prop.PropertyType;
if (propType == typeof(String))
prop.SetValue(entity, reader.GetString(i), null);
else if (propType == typeof(ServerEntityKey))
{
Guid uid = reader.GetGuid(i);
prop.SetValue(entity, new ServerEntityKey(columnName.Replace("Key", String.Empty), uid), null);
}
else if (propType == typeof(DateTime))
prop.SetValue(entity, reader.GetDateTime(i), null);
else if (propType == typeof(DateTime?))
{
if (reader.IsDBNull(i))
{
prop.SetValue(entity, null, null);
}
else
{
prop.SetValue(entity, reader.GetDateTime(i), null);
}
}
else if (propType == typeof(bool))
prop.SetValue(entity, reader.GetBoolean(i), null);
else if (propType == typeof(Int32))
prop.SetValue(entity, reader.GetInt32(i), null);
else if (propType == typeof(Int16))
prop.SetValue(entity, reader.GetInt16(i), null);
else if (propType == typeof(double))
prop.SetValue(entity, reader.GetDouble(i), null);
else if (propType == typeof(Decimal))
prop.SetValue(entity, reader.GetDecimal(i), null);
else if (propType == typeof(float))
prop.SetValue(entity, reader.GetFloat(i), null);
else if (propType == typeof(XmlDocument))
{
SqlXml xml = reader.GetSqlXml(i);
if (xml!=null && !xml.IsNull)
{
XmlReader xmlReader = xml.CreateReader();
if (xmlReader != null)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlReader);
prop.SetValue(entity, xmlDoc, null);
}
else
prop.SetValue(entity, null, null);
}
else
{
prop.SetValue(entity, null, null);
}
}
else if (typeof(ServerEnum).IsAssignableFrom(propType))
{
short enumVal = reader.GetInt16(i);
ConstructorInfo construct = prop.PropertyType.GetConstructor(new Type[0]);
ServerEnum val = (ServerEnum)construct.Invoke(null);
val.SetEnum(enumVal);
prop.SetValue(entity, val, null);
}
else
throw new EntityNotFoundException("Unsupported property type: " + propType, null);
}
}