本文整理汇总了C#中System.Data.OleDb.OleDbDataReader.GetOrdinal方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbDataReader.GetOrdinal方法的具体用法?C# OleDbDataReader.GetOrdinal怎么用?C# OleDbDataReader.GetOrdinal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.OleDb.OleDbDataReader
的用法示例。
在下文中一共展示了OleDbDataReader.GetOrdinal方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadRow
public void LoadRow(OleDbDataReader reader)
{
var schema = reader.GetSchemaTable();
foreach (var pi in this.GetType().GetProperties())
{
if (schema.Select("ColumnName='" + pi.Name + "'").Length > 0)
{
var value = reader.GetValue(reader.GetOrdinal(pi.Name));
if (value != null)
pi.SetValue(this, value, null);
}
}
}
示例2: GetSubmissionsQueryCallback
protected List<DBItem> GetSubmissionsQueryCallback(OleDbDataReader reader)
{
List<DBItem> returnList = new List<DBItem>();
if (reader.HasRows)
{
while (reader.Read())
{
DBItem item = new DBItem();
item.ID = reader.GetInt32(reader.GetOrdinal("ID"));
item.User = reader.GetString(reader.GetOrdinal("User"));
item.DateTime = reader.GetDateTime(reader.GetOrdinal("DateTime"));
item.Person = reader.GetString(reader.GetOrdinal("Person"));
item.Rating = reader.GetString(reader.GetOrdinal("Rating"));
item.Description = reader.GetString(reader.GetOrdinal("Description"));
item.Votes = reader.GetString(reader.GetOrdinal("Votes"));
returnList.Add(item);
}
}
return returnList;
}
示例3: GetVotesQueryCallback
protected List<DBItem> GetVotesQueryCallback(OleDbDataReader reader)
{
List<DBItem> returnList = new List<DBItem> { };
if (reader.HasRows)
{
while (reader.Read())
{
DBItem item = new DBItem();
item.Votes = reader.GetString(reader.GetOrdinal("Votes"));
returnList.Add(item);
}
}
return returnList;
}
示例4: SelectTask
//Select by specific column and value
public Angar SelectTask(string tableName, string columnName, string value, string comma)
{
Loader();
string SQL = "SELECT * FROM " + tableName + " WHERE "+columnName+"=" +comma+ value +comma+ ";";
Angar answer;
answer = new Angar();
Reader = Execute(SQL);
while (Reader.Read())
{
Task temp;
temp = new Task();
//DO IT
temp.Body = Reader.GetValue(Reader.GetOrdinal("Body")).ToString();
temp.Header = Reader.GetValue(Reader.GetOrdinal("Header")).ToString();
temp.Worker = Reader.GetValue(Reader.GetOrdinal("Worker")).ToString();
temp.ID = Convert.ToInt64(Reader.GetValue(Reader.GetOrdinal("ID")));
temp.IsDone = (bool)Reader.GetValue(Reader.GetOrdinal("IsDone"));
temp.Date = Convert.ToDateTime(Reader.GetValue(Reader.GetOrdinal("TargetDate")));
answer.Storage.Add(temp);
}
return answer;
}
示例5: SelectById
public Task SelectById(string tableName, long id)
{
string SQL = "SELECT * FROM "+tableName+" WHERE ID="+id.ToString()+" ;";
Reader = Execute(SQL);
Reader.Read();
Task temp;
temp=new Task();
//DO IT
temp.Body = Reader.GetValue(Reader.GetOrdinal("Body")).ToString();
temp.Header = Reader.GetValue(Reader.GetOrdinal("Header")).ToString();
temp.Worker = Reader.GetValue(Reader.GetOrdinal("Worker")).ToString();
temp.ID =Convert.ToInt64( Reader.GetValue(Reader.GetOrdinal("ID")));
temp.IsDone =(bool) Reader.GetValue(Reader.GetOrdinal("IsDone"));
temp.Date =Convert.ToDateTime( Reader.GetValue(Reader.GetOrdinal("TargetDate")));
return temp;
}
示例6: MinDate
public void MinDate()
{
BeginCase("Test Min date.");
exp = null;
string[] dateColumns;
DateTime[] expectedValues;
InitMinDates(out dateColumns, out expectedValues);
try
{
con = new OleDbConnection(ConnectedDataProvider.ConnectionString);
cmd = new OleDbCommand();
cmd.Connection = con;
cmd.CommandText = BuildMinDateTimeSelectSql(dateColumns);
con.Open();
rdr = cmd.ExecuteReader();
Compare(true, rdr.HasRows);
bool b = rdr.Read();
for (int i=0; i<dateColumns.Length && i<expectedValues.Length; i++)
{
int j=-1;
j = rdr.GetOrdinal(dateColumns[i]);
//DateTime result = rdr.GetDateTime(j);
object result = rdr.GetValue(j);
Compare(result, expectedValues[i]);
}
}
catch (Exception ex)
{
exp = ex;
}
finally
{
if (rdr != null && !rdr.IsClosed)
{
rdr.Close();
}
if (con != null && con.State != ConnectionState.Closed)
{
con.Close();
}
EndCase(exp);
}
}
示例7: Construct
private void Construct(OleDbDataReader oReader, object myobj)
{
PropertyInfo t = null;
object tvalue = new object();
Type myType = myobj.GetType();
ObjectRights objectRights = new ObjectRights();
t = myType.GetProperty("constructing");
t.SetValue(myobj, true, null);
if (oReader.HasRows)
{
List<IntelWebField> tempList;
if (this.selectFieldsList.Count > 0)
{
tempList = this.selectFieldsList;
}
else
{
tempList = this.FieldList;
}
t = myType.GetProperty("isNew");
t.SetValue(myobj, false, null);
foreach (IntelWebField x in tempList)
{
t = myType.GetProperty(x.name);
tvalue = oReader.GetValue(oReader.GetOrdinal(x.name));
if (DBNull.Equals(DBNull.Value, tvalue))
{
tvalue = null;
}
t.SetValue(myobj, tvalue, null);
}
if (_hasPK) { setPK(myobj); }
t = myType.GetProperty("isDirty");
t.SetValue(myobj, false, null);
}
else
{
t = myType.GetProperty("isNew");
t.SetValue(myobj, true, null);
t = myType.GetProperty("isDirty");
t.SetValue(myobj, true, null);
}
PropertyInfo tprop = myType.GetProperty("constructing");
tprop.SetValue(myobj, false, null);
}