本文整理汇总了C#中System.Data.OleDb.OleDbDataReader.GetValues方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbDataReader.GetValues方法的具体用法?C# OleDbDataReader.GetValues怎么用?C# OleDbDataReader.GetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.OleDb.OleDbDataReader
的用法示例。
在下文中一共展示了OleDbDataReader.GetValues方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Open
public void Open(String filename, string sheetName)
{
var conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filename + ";Extended Properties=\"" + "Excel 12.0 Xml;HDR=YES;IMEX=1;" + "\"");
conn.Open();
var comm = new OleDbCommand("Select * from [" + sheetName + "]", conn);
reader = comm.ExecuteReader(CommandBehavior.SingleResult);
records.Clear();
while (reader.Read())
{
fields = new object[reader.FieldCount];
var fieldcount = reader.GetValues(fields);
records.Add(fields);
}
//reader.
}
示例2: ExcelReader
private ExcelReader(string fileName, ExcelSchema schema, ExcelOptions options, bool hasSchema)
{
if (!File.Exists(fileName))
{
throw new FileNotFoundException(Resources.FileNotFound, fileName);
}
if (hasSchema && schema == null)
{
throw new ArgumentNullException("schema");
}
if (options == null)
{
throw new ArgumentNullException("options");
}
this.options = options;
string connectionString = ExcelHelpers.GetConnectionString(fileName);
connection = new OleDbConnection(connectionString);
connection.Open();
command = connection.CreateCommand();
command.CommandText = ExcelHelpers.GetSelectCommandText(schema, options);
dataReader = command.ExecuteReader();
if (hasSchema)
{
if (options.IsFirstRecordSchema)
{
dataReader.Read(); // skip header record
}
this.schema = schema;
}
else if (options.IsFirstRecordSchema && dataReader.Read())
{
object[] values = new object[dataReader.FieldCount];
dataReader.GetValues(values);
int startingIndex = ExcelHelpers.GetExcelColumnIndex(options.StartingColumn ?? "A");
this.schema = new ExcelSchema();
for (int valueIndex = 0; valueIndex != values.Length; ++valueIndex)
{
object value = values[valueIndex];
string columnName = getColumnName(startingIndex + valueIndex, value);
StringColumn column = new StringColumn(columnName);
this.schema.AddColumn(column);
}
}
}
示例3: loadDataForSteel
private void loadDataForSteel()
{
//MessageBox.Show("loadDataForSteel()");
// Data from DATA1-STEEL - Variable
string sql2 = "Select * from Steel where id_steel like '1'";
dat_reader = dat_conn.getDBReader(sql2);
dat_reader.Read();
dat_reader.GetValues(collection4);
// Data from DATA1-STEEL - Variable Table name
sql2 = "Select * from Steel where id_steel like '2'";
dat_reader = dat_conn.getDBReader(sql2);
dat_reader.Read();
dat_reader.GetValues(collection5);
// Data from DATA1-STEEL - Units
sql2 = "Select * from Steel where id_steel like '3'";
dat_reader = dat_conn.getDBReader(sql2);
dat_reader.Read();
dat_reader.GetValues(collection6);
// STEEL VARIABLES CHECKED LIST BOX 4
//ide sa od indexu 3 lebo prve tri stlpce z databazy vynechavame
for (int i = 3; i < collection4.Count(); i++)
{
//loading data from database to lists ZoznamPremennych,ZoznamZobrazPremennych,ZoznamJednotiek
infoSteel.ZoznamPremennych.Add(collection4[i].ToString());
infoSteel.ZoznamZobrazPremennych.Add(collection5[i].ToString());
infoSteel.ZoznamJednotiek.Add(collection6[i].ToString());
infoSteel.ZoznamZasktPrem.Add(false);
}
zozChLInfos[0, 0] = infoSteel;
this.SaveData();
}
示例4: loadDataForSection
private void loadDataForSection(byte typ_prierezu)
{
//MessageBox.Show("loadDataForSection()"+typ_prierezu);
// Data from DATA1-SECTIONS_VAR2 - Variable
string sql = "Select * from sections_var2 where csprofshape_var like '" + typ_prierezu + "'";
dat_reader = dat_conn.getDBReader(sql);
dat_reader.Read();
dat_reader.GetValues(collection1);
// Data from DATA1-SECTIONS_VAR2 - Variable Table Name
sql = "Select * from sections_var2 where id_sections_var2 like '1'";
dat_reader = dat_conn.getDBReader(sql);
dat_reader.Read();
dat_reader.GetValues(collection2);
// Data from DATA1-SECTIONS_VAR2 - Units
sql = "Select * from sections_var2 where id_sections_var2 like '3'";
dat_reader = dat_conn.getDBReader(sql);
dat_reader.Read();
dat_reader.GetValues(collection3);
// SECTION VARIABLES CHECKED LIST BOX 1
//prvych 5 stlpcov v databaze vynechavame
info1 = new CheckedListInfo();
for (int i = 5; i < collection1.Count(); i++)
{
if (!collection1[i].ToString().Equals(""))
{
info1.ZoznamPremennych.Add(collection1[i].ToString());
info1.ZoznamZobrazPremennych.Add(collection2[i].ToString());
info1.ZoznamJednotiek.Add(collection3[i].ToString());
info1.ZoznamZasktPrem.Add(false);
}
}
zozChLInfos[typ_prierezu, 0] = info1;
this.SaveData();
}