本文整理汇总了C#中System.Data.OleDb.OleDbCommand.Read方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbCommand.Read方法的具体用法?C# OleDbCommand.Read怎么用?C# OleDbCommand.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.OleDb.OleDbCommand
的用法示例。
在下文中一共展示了OleDbCommand.Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetReportData
public static List<AvgSpeedReportItem> GetReportData()
{
string query =
@"WITH RankedLink AS (
SELECT ROW_NUMBER() OVER (ORDER BY Link, SegEndC) [Number], *
FROM dbo.Olaine_LINK_EVAL),
MiddleLink AS (
SELECT AVG(Number) [MiddleLink]
FROM RankedLink
GROUP BY Link),
AvgSpeed AS (
SELECT AVG(v__0_) [speed], Link
FROM dbo.Olaine_LINK_EVAL
GROUP BY Link)
SELECT RankedLink.Link, 0 [Lane], (SegStX + SegEndX)/2 [center.x], (SegStY + SegEndY)/2 [center.y], AvgSpeed.speed
FROM RankedLink
JOIN MiddleLink ON RankedLink.Number=MiddleLink.MiddleLink
JOIN AvgSpeed ON RankedLink.Link=AvgSpeed.Link";
var list = new List<AvgSpeedReportItem>();
try
{
var sb = new OleDbConnectionStringBuilder(vissim.Instance.Evaluation.Wrap().GetConnectionString());
if (sb.ContainsKey("Password"))
{
using (var conn = new OleDbConnection(sb.ConnectionString))
{
conn.Open();
try
{
using (var reader = new OleDbCommand(query, conn).ExecuteReader())
{
while (reader.Read())
{
list.Add(new AvgSpeedReportItem()
{
Link = reader.GetInt32(0),
Lane = reader.GetInt32(1),
Center = new Point(reader.GetDouble(2), reader.GetDouble(3)),
AvgSpeed = reader.GetDouble(4)
});
}
}
}
finally
{
conn.Close();
}
}
}
}
catch { }
return list;
}
示例2: ImportDataFromExcelEquity
public void ImportDataFromExcelEquity()
{
string excelFilePath = "C:/Users/ahksysuser06/Desktop/EDISData/International_Equity_Daily_Closing_Price_20131211.xlsx";
// make sure your sheet name is correct, here sheet name is sheet1, so you can change the sheet name if have different
string excelQuery = "select SecId,Name,Symbol from [Sheet1$]";
try
{
string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excelFilePath +
";Extended Properties='Excel 12.0;HDR=YES;IMEX=1;'";
OleDbConnection oleConn = new OleDbConnection(excelConnectionString);
oleConn.Open();
OleDbDataReader oleReader = new OleDbCommand(excelQuery, oleConn).ExecuteReader();
//while (oleReader.Read())
//{
// Domain.Portfolio.AggregateRoots.Asset.Equity equity = new AustralianEquity(edisRepo)
// {
// Name = oleReader.GetString(1),
// Sector = oleReader.GetString(0),
// Ticker = oleReader.GetString(2),
// EquityType = EquityTypes.AustralianEquity,
// };
// edisRepo.InsertEquityData(equity);
//}
while (oleReader.Read())
{
Domain.Portfolio.AggregateRoots.Asset.Equity equity = new InternationalEquity(edisRepo)
{
Name = oleReader.GetString(1),
Sector = oleReader.GetString(0),
Ticker = oleReader.GetString(2),
EquityType = EquityTypes.InternationalEquity,
};
edisRepo.InsertEquityData(equity);
}
oleReader.Close();
oleConn.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
示例3: LoadIdealTendencyKind
public List<string> LoadIdealTendencyKind(OleDbConnection connection, GameScenario scen)
{
connection.Open();
OleDbDataReader reader = new OleDbCommand("Select * From IdealTendencyKind", connection).ExecuteReader();
while (reader.Read())
{
IdealTendencyKind t = new IdealTendencyKind();
t.Scenario = scen;
t.ID = (short)reader["ID"];
t.Name = reader["Name"].ToString();
t.Offset = (short)reader["Offset"];
this.AllIdealTendencyKinds.Add(t);
}
connection.Close();
return new List<string>();
}
示例4: LoadFromDatabase
public bool LoadFromDatabase(string connectionString)
{
int num;
Animation animation;
OleDbConnection connection = new OleDbConnection(connectionString);
connection.Open();
OleDbDataReader reader = new OleDbCommand("Select * From TerrainDetail", connection).ExecuteReader();
while (reader.Read())
{
TerrainDetail terrainDetail = new TerrainDetail();
terrainDetail.ID = (short)reader["ID"];
terrainDetail.Name = reader["Name"].ToString();
terrainDetail.GraphicLayer = (int)reader["GraphicLayer"];
terrainDetail.ViewThrough = (bool)reader["ViewThrough"];
terrainDetail.RoutewayBuildFundCost = (int)reader["RoutewayBuildFundCost"];
terrainDetail.RoutewayActiveFundCost = (int)reader["RoutewayActiveFundCost"];
terrainDetail.RoutewayBuildWorkCost = (int)reader["RoutewayBuildWorkCost"];
terrainDetail.RoutewayConsumptionRate = (float)reader["RoutewayConsumptionRate"];
terrainDetail.FoodDeposit = (int)reader["FoodDeposit"];
terrainDetail.FoodRegainDays = (int)reader["FoodRegainDays"];
terrainDetail.FoodSpringRate = (float)reader["FoodSpringRate"];
terrainDetail.FoodSummerRate = (float)reader["FoodSummerRate"];
terrainDetail.FoodAutumnRate = (float)reader["FoodAutumnRate"];
terrainDetail.FoodWinterRate = (float)reader["FoodWinterRate"];
terrainDetail.FireDamageRate = (float)reader["FireDamageRate"];
this.AllTerrainDetails.AddTerrainDetail(terrainDetail);
}
connection.Close();
connection.Open();
reader = new OleDbCommand("Select * From Color", connection).ExecuteReader();
while (reader.Read())
{
Color item = new Color();
item.PackedValue = uint.Parse(reader["Code"].ToString());
this.AllColors.Add(item);
}
connection.Close();
connection.Open();
reader = new OleDbCommand("Select * From IdealTendencyKind", connection).ExecuteReader();
while (reader.Read())
{
IdealTendencyKind t = new IdealTendencyKind();
t.ID = (short)reader["ID"];
t.Name = reader["Name"].ToString();
t.Offset = (short)reader["Offset"];
this.AllIdealTendencyKinds.Add(t);
}
connection.Close();
connection.Open();
reader = new OleDbCommand("Select * From CharacterKind", connection).ExecuteReader();
while (reader.Read())
{
CharacterKind kind2 = new CharacterKind();
kind2.ID = (short)reader["ID"];
kind2.Name = reader["Name"].ToString();
kind2.IntelligenceRate = (float)reader["IntelligenceRate"];
kind2.ChallengeChance = (short)reader["ChallengeChance"];
kind2.ControversyChance = (short)reader["ControversyChance"];
this.AllCharacterKinds.Add(kind2);
}
connection.Close();
connection.Open();
reader = new OleDbCommand("Select * From ArchitectureKind", connection).ExecuteReader();
while (reader.Read())
{
ArchitectureKind architectureKind = new ArchitectureKind();
architectureKind.ID = (short)reader["ID"];
architectureKind.Name = reader["Name"].ToString();
architectureKind.AgricultureBase = (short)reader["AgricultureBase"];
architectureKind.AgricultureUnit = (short)reader["AgricultureUnit"];
architectureKind.CommerceBase = (short)reader["CommerceBase"];
architectureKind.CommerceUnit = (short)reader["CommerceUnit"];
architectureKind.TechnologyBase = (short)reader["TechnologyBase"];
architectureKind.TechnologyUnit = (short)reader["TechnologyUnit"];
architectureKind.DominationBase = (short)reader["DominationBase"];
architectureKind.DominationUnit = (short)reader["DominationUnit"];
architectureKind.MoraleBase = (short)reader["MoraleBase"];
architectureKind.MoraleUnit = (short)reader["MoraleUnit"];
architectureKind.EnduranceBase = (short)reader["EnduranceBase"];
architectureKind.EnduranceUnit = (short)reader["EnduranceUnit"];
architectureKind.PopulationBase = (int)reader["PopulationBase"];
architectureKind.PopulationUnit = (int)reader["PopulationUnit"];
architectureKind.PopulationBoundary = (int)reader["PopulationBoundary"];
architectureKind.ViewDistance = (short)reader["ViewDistance"];
architectureKind.ViewDistanceIncrementDivisor = (short)reader["VDIncrementDivisor"];
architectureKind.HasObliqueView = (bool)reader["HasObliqueView"];
architectureKind.HasLongView = (bool)reader["HasLongView"];
architectureKind.HasPopulation = (bool)reader["HasPopulation"];
architectureKind.HasAgriculture = (bool)reader["HasAgriculture"];
architectureKind.HasCommerce = (bool)reader["HasCommerce"];
architectureKind.HasTechnology = (bool)reader["HasTechnology"];
architectureKind.HasDomination = (bool)reader["HasDomination"];
architectureKind.HasMorale = (bool)reader["HasMorale"];
architectureKind.HasEndurance = (bool)reader["HasEndurance"];
architectureKind.HasHarbor = (bool)reader["HasHarbor"];
architectureKind.FacilityPositionUnit = (short)reader["FacilityPositionUnit"];
architectureKind.FundMaxUnit = (int)reader["FundMaxUnit"];
architectureKind.FoodMaxUnit = (int)reader["FoodMaxUnit"];
try
{
//.........这里部分代码省略.........
示例5: LoadTroopAnimation
public List<string> LoadTroopAnimation(OleDbConnection connection, GameScenario scen)
{
connection.Open();
OleDbDataReader reader = new OleDbCommand("Select * From TroopAnimation", connection).ExecuteReader();
while (reader.Read())
{
Animation animation = new Animation();
animation.Scenario = scen;
animation.ID = (short)reader["ID"];
animation.Name = reader["Name"].ToString();
animation.FrameCount = (short)reader["FrameCount"];
animation.StayCount = (short)reader["StayCount"];
this.AllTroopAnimations.AddAnimation(animation);
}
connection.Close();
return new List<string>();
}
示例6: LoadPersonGeneratorTypes
public List<string> LoadPersonGeneratorTypes(OleDbConnection connection, GameScenario scen)
{
connection.Open();
OleDbDataReader reader = new OleDbCommand("Select * From PersonGeneratorType", connection).ExecuteReader();
bool hasZero = false;
while (reader.Read())
{
PersonGeneratorType type = new PersonGeneratorType();
type.ID = (int)reader["ID"];
if (type.ID == 0)
{
hasZero = true;
}
type.Name = reader["TypeName"].ToString();
type.generationChance = (int)reader["GenerationChance"];
type.commandLo = (int)reader["CommandLo"];
type.commandHi = (int)reader["CommandHi"];
type.strengthLo = (int)reader["StrengthLo"];
type.strengthHi = (int)reader["StrengthHi"];
type.intelligenceLo = (int)reader["IntelligenceLo"];
type.intelligenceHi = (int)reader["IntelligenceHi"];
type.politicsLo = (int)reader["PoliticsLo"];
type.politicsHi = (int)reader["PoliticsHi"];
type.glamourLo = (int)reader["GlamourLo"];
type.glamourHi = (int)reader["GlamourHi"];
type.braveLo = (int)reader["BraveLo"];
type.braveHi = (int)reader["BraveHi"];
type.calmnessLo = (int)reader["CalmnessLo"];
type.calmnessHi = (int)reader["CalmnessHi"];
type.personalLoyaltyLo = (int)reader["PersonalLoyaltyLo"];
type.personalLoyaltyHi = (int)reader["PersonalLoyaltyHi"];
type.ambitionLo = (int)reader["AmbitionLo"];
type.ambitionHi = (int)reader["AmbitionHi"];
type.titleChance = (int)reader["TitleChance"];
type.affectedByRateParameter = (bool)reader["AffectedByRateParameter"];
this.AllPersonGeneratorTypes.Add(type);
}
connection.Close();
// for backward compatibility
if (!hasZero)
{
foreach (PersonGeneratorType type in this.AllPersonGeneratorTypes)
{
type.ID--;
}
}
return new List<string>();
}
示例7: DLookup
public object DLookup(string sqlQuery)
{
object data = null;
bool connectedP = isConnectedDo;
try
{
if (dbType == DatabaseType.MSSQL)
{
getQueryDbChanger(sqlQuery, SqlTypes.SELECT);
SqlDataReader Dr = new SqlCommand(sqlQuery, MSSQLConn).ExecuteReader();
if (Dr.Read())
{
data = Dr[0];
}
Dr.Close();
}
else if (dbType == DatabaseType.MYSQL)
{
MySqlDataReader Dr = new MySqlCommand(sqlQuery, MySQLConn).ExecuteReader();
if (Dr.Read())
{
data = Dr[0];
}
Dr.Close();
}
else if (dbType == DatabaseType.MSACCESS2003 | dbType == DatabaseType.MSACCESS2007)
{
OleDbDataReader Dr = new OleDbCommand(sqlQuery, MSDBSQLConn).ExecuteReader();
if (Dr.Read())
{
data = Dr[0];
}
Dr.Close();
}
}
catch (Exception eee)
{
OnError(eee);
data = eee.Message;
}
finally
{
if (!connectedP)
closeConnection();
}
return data;
}
示例8: LoadInformationKind
public List<string> LoadInformationKind(OleDbConnection connection, GameScenario scen)
{
connection.Open();
OleDbDataReader reader = new OleDbCommand("Select * From InformationKind", connection).ExecuteReader();
while (reader.Read())
{
InformationKind kind9 = new InformationKind();
kind9.Scenario = scen;
kind9.ID = (short)reader["ID"];
kind9.Level = (InformationLevel)((short)reader["iLevel"]);
kind9.Oblique = (bool)reader["Oblique"];
kind9.Radius = (short)reader["Radius"];
kind9.CostFund = (int)reader["CostFund"];
this.AllInformationKinds.Add(kind9);
}
connection.Close();
return new List<string>();
}
示例9: LoadOfficeKind
public List<string> LoadOfficeKind(OleDbConnection connection, GameScenario scen)
{
connection.Open();
OleDbDataReader reader = new OleDbCommand("Select * From guanjuezhonglei", connection).ExecuteReader();
while (reader.Read())
{
guanjuezhongleilei guanjuedezhonglei = new guanjuezhongleilei();
guanjuedezhonglei.Scenario = scen;
guanjuedezhonglei.ID = (short)reader["ID"];
guanjuedezhonglei.Name = reader["名称"].ToString();
guanjuedezhonglei.shengwangshangxian = (int)reader["声望上限"];
guanjuedezhonglei.xuyaogongxiandu = (int)reader["需要贡献度"];
guanjuedezhonglei.xuyaochengchi = (short)reader["需要城池"];
guanjuedezhonglei.ShowDialog = (bool)reader["ShowDialog"];
this.suoyouguanjuezhonglei.Addguanjuedezhonglei(guanjuedezhonglei);
}
connection.Close();
return new List<string>();
}
示例10: LoadColor
public List<string> LoadColor(OleDbConnection connection, GameScenario scen)
{
connection.Open();
OleDbDataReader reader = new OleDbCommand("Select * From Color", connection).ExecuteReader();
while (reader.Read())
{
Color item = new Color();
item.PackedValue = uint.Parse(reader["Code"].ToString());
this.AllColors.Add(item);
}
connection.Close();
return new List<string>();
}
示例11: LoadCombatMethodKind
public List<string> LoadCombatMethodKind(OleDbConnection connection, GameScenario scen)
{
List<string> errorMsg = new List<string>();
connection.Open();
OleDbDataReader reader = new OleDbCommand("Select * From CombatMethod", connection).ExecuteReader();
while (reader.Read())
{
CombatMethod combatMethod = new CombatMethod();
combatMethod.Scenario = scen;
combatMethod.ID = (short)reader["ID"];
combatMethod.Name = reader["Name"].ToString();
combatMethod.Description = reader["Description"].ToString();
combatMethod.Combativity = (short)reader["Combativity"];
List<string> e = combatMethod.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
combatMethod.AttackDefault = this.AllAttackDefaultKinds.GetGameObject((short)reader["AttackDefault"]) as AttackDefaultKind;
combatMethod.AttackTarget = this.AllAttackTargetKinds.GetGameObject((short)reader["AttackTarget"]) as AttackTargetKind;
combatMethod.ArchitectureTarget = (bool)reader["ArchitectureTarget"];
e.AddRange(combatMethod.CastConditions.LoadFromString(this.AllConditions, reader["CastConditions"].ToString()));
if (e.Count > 0)
{
errorMsg.Add("战法ID" + combatMethod.ID);
errorMsg.AddRange(e);
}
combatMethod.ViewingHostile = (bool)reader["ViewingHostile"];
combatMethod.AnimationKind = (TileAnimationKind)((short)reader["AnimationKind"]);
this.AllCombatMethods.AddCombatMethod(combatMethod);
}
connection.Close();
return errorMsg;
}
示例12: LoadCastTargetKind
public List<string> LoadCastTargetKind(OleDbConnection connection, GameScenario scen)
{
connection.Open();
OleDbDataReader reader = new OleDbCommand("Select * From CastTargetKind", connection).ExecuteReader();
while (reader.Read())
{
CastTargetKind kind13 = new CastTargetKind();
kind13.Scenario = scen;
kind13.ID = (short)reader["ID"];
kind13.Name = reader["Name"].ToString();
this.AllCastTargetKinds.Add(kind13);
}
connection.Close();
return new List<string>();
}
示例13: LoadCharacterKind
public List<string> LoadCharacterKind(OleDbConnection connection, GameScenario scen)
{
connection.Open();
OleDbDataReader reader = new OleDbCommand("Select * From CharacterKind", connection).ExecuteReader();
while (reader.Read())
{
CharacterKind kind2 = new CharacterKind();
kind2.Scenario = scen;
kind2.ID = (short)reader["ID"];
kind2.Name = reader["Name"].ToString();
kind2.IntelligenceRate = (float)reader["IntelligenceRate"];
kind2.ChallengeChance = (short)reader["ChallengeChance"];
kind2.ControversyChance = (short)reader["ControversyChance"];
kind2.GenerationChance[0] = (int)reader["General"];
kind2.GenerationChance[1] = (int)reader["Brave"];
kind2.GenerationChance[2] = (int)reader["Advisor"];
kind2.GenerationChance[3] = (int)reader["Politician"];
kind2.GenerationChance[4] = (int)reader["IntelGeneral"];
kind2.GenerationChance[5] = (int)reader["Emperor"];
kind2.GenerationChance[6] = (int)reader["AllRounder"];
kind2.GenerationChance[7] = (int)reader["Normal"];
kind2.GenerationChance[8] = (int)reader["Cheap"];
try
{
kind2.GenerationChance[9] = (int)reader["Normal2"];
}
catch
{
kind2.GenerationChance[9] = kind2.GenerationChance[7];
}
this.AllCharacterKinds.Add(kind2);
}
connection.Close();
return new List<string>();
}
示例14: LoadBiographyAdjectives
public List<string> LoadBiographyAdjectives(OleDbConnection connection, GameScenario scen)
{
connection.Open();
OleDbDataReader reader = new OleDbCommand("Select * From BiographyAdjectives", connection).ExecuteReader();
while (reader.Read())
{
int t;
BiographyAdjectives b = new BiographyAdjectives();
b.Scenario = scen;
b.ID = (short)reader["ID"];
int.TryParse(reader["Strength"].ToString(), out t);
b.Strength = t;
b.ID = (short)reader["ID"];
int.TryParse(reader["Command"].ToString(), out t);
b.Command = t;
b.ID = (short)reader["ID"];
int.TryParse(reader["Intelligence"].ToString(), out t);
b.Intelligence = t;
b.ID = (short)reader["ID"];
int.TryParse(reader["Politics"].ToString(), out t);
b.Politics = t;
b.ID = (short)reader["ID"];
int.TryParse(reader["Glamour"].ToString(), out t);
b.Glamour = t;
b.ID = (short)reader["ID"];
int.TryParse(reader["Braveness"].ToString(), out t);
b.Braveness = t;
b.ID = (short)reader["ID"];
int.TryParse(reader["Calmness"].ToString(), out t);
b.Calmness = t;
b.ID = (short)reader["ID"];
int.TryParse(reader["PersonalLoyalty"].ToString(), out t);
b.PersonalLoyalty = t;
b.ID = (short)reader["ID"];
int.TryParse(reader["Ambition"].ToString(), out t);
b.Ambition = t;
b.Male = (bool)reader["Male"];
b.Female = (bool)reader["Female"];
StaticMethods.LoadFromString(b.Text, reader["BioText"].ToString());
StaticMethods.LoadFromString(b.SuffixText, reader["SuffixText"].ToString());
this.AllBiographyAdjectives.Add(b);
}
connection.Close();
return new List<string>();
}
示例15: LoadAttackDefaultKind
public List<string> LoadAttackDefaultKind(OleDbConnection connection, GameScenario scen)
{
connection.Open();
OleDbDataReader reader = new OleDbCommand("Select * From AttackDefaultKind", connection).ExecuteReader();
while (reader.Read())
{
AttackDefaultKind kind10 = new AttackDefaultKind();
kind10.Scenario = scen;
kind10.ID = (short)reader["ID"];
kind10.Name = reader["Name"].ToString();
this.AllAttackDefaultKinds.Add(kind10);
}
connection.Close();
return new List<string>();
}