本文整理汇总了C#中System.Data.OleDb.OleDbCommand.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbCommand.GetString方法的具体用法?C# OleDbCommand.GetString怎么用?C# OleDbCommand.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.OleDb.OleDbCommand
的用法示例。
在下文中一共展示了OleDbCommand.GetString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: caricaDaDb
void caricaDaDb()
{
string sconn;
sconn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb";
OleDbConnection conn = new OleDbConnection(sconn);
try
{
conn.Open();
N_NODI = getint32("SELECT valore FROM parametri WHERE parametro='n' ", 0, conn);
settaNnodi(N_NODI);
m = getint32("SELECT valore FROM parametri WHERE parametro='m' ", 0, conn);
//leggo nodi
OleDbDataReader myreader = new OleDbCommand("select x,y,nome from nodi", conn).ExecuteReader();
for (int i = 0; i < N_NODI; i++)
{
nodi[i].x = nodi[i].y = 0;
archi[i] = new ArrayList();
d[i] = new ArrayList();
}
while (myreader.Read())
{
int x;
int y;
int nome;
//int a, b, c;
//myreader.Read();
x = myreader.GetInt32(0);
y = myreader.GetInt32(1);
nome = Convert.ToInt32(myreader.GetString(2));
nodi[nome].x = x;
nodi[nome].y = y;
nodi[nome].name = Convert.ToString(nome);
archi[nome] = new ArrayList();
d[nome] = new ArrayList();
}
//leggo archi
myreader = new OleDbCommand("select x,y,dist from archi", conn).ExecuteReader();
//for (int j = 0; j < m; j++) // per ogni arco...
while (myreader.Read())
{
int from;
int dest;
int dist;
//myreader.Read();
from = myreader.GetInt32(0);
dest = myreader.GetInt32(1);
dist = myreader.GetInt32(2);
//aggiungo arco
if (archi[from] == null)
archi[from] = new ArrayList();
if (d[from] == null)
d[from] = new ArrayList();
archi[from].Add(dest);
d[from].Add(dist);
}
DrawGraph();
conn.Close();
}
catch (OleDbException e)
{
MessageBox.Show("Errore DB" + e.Message);
}
}