本文整理汇总了C#中System.Data.OleDb.OleDbDataReader.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbDataReader.GetString方法的具体用法?C# OleDbDataReader.GetString怎么用?C# OleDbDataReader.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.OleDb.OleDbDataReader
的用法示例。
在下文中一共展示了OleDbDataReader.GetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddNodeItem
protected override TreeNode AddNodeItem(TreeNode aTn, OleDbDataReader aReader, ref int aSI)
{
/// В pSQLString должен быть определен примерно такой select:
/// ...
/// SELECT
/// refCode, refBName, 1, ...
/// FROM
/// rbRef
/// ...
TreeNode ntn = new TreeNode(aReader.GetString(1));
PCTVItemData tid = new PCTVItemData();
ntn.Tag = tid;
tid.pPC.code = aReader.GetInt32(0);
/// Added M.Tor 25.06.2008:
tid.pText = aReader.GetString(1);
if (aReader.GetInt32(2) > 0)
ntn.Nodes.Add(new TreeNode());
if (aTn == null)
{
Nodes.Add(ntn);
tid.pPath = tid.pCode.ToString();
}
else
{
aTn.Nodes.Add(ntn);
tid.pPath = ((PCTVItemData)aTn.Tag).pPath + pPathDelim + tid.pCode;
}
aSI = 3;
return ntn;
}
示例2: Initialise
public void Initialise()
{
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=phonebook.accdb";
OleDbConnection conn = new OleDbConnection(connectionString);
string sql = "SELECT * FROM task ORDER BY id";
OleDbCommand cmd = new OleDbCommand(sql, conn);
try
{
conn.Open();
reader = cmd.ExecuteReader();
reader.Read();
lblTask.Text = reader.GetString(1).ToString();
txtTask.Text = reader.GetString(2).ToString();
reader.Close();
conn.Close();
}
catch
{
//MessageBox.Show(e.Message);
}
}
示例3: Login
// Constructor for searched login
public Login(uint gloid)
{
// Declarations
uint gvoid = 0, modifiedby = 0;
string username = null, password = null, note = null, status = null;
bool active = false;
DateTime datemodified = new DateTime(1901, 1, 1);
// Command
string query = string.Format("SELECT glo_username, glo_password, glo_note, glo_active, glo_status, gvo_id, date_modified, modified_by FROM gfrc_login" +
" WHERE glo_id = {0}", gloid);
try
{
using (conn)
{
conn.Open();
cmd = new OleDbCommand(query, conn);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
username = rdr.GetString(0);
password = rdr.GetString(1);
note = rdr.GetString(2);
active = rdr.GetBoolean(3);
status = rdr.GetString(4);
if (!UInt32.TryParse(rdr.GetValue(5).ToString(), out gvoid))
gvoid = 0;
if (!DateTime.TryParse(rdr.GetValue(6).ToString(), out datemodified))
datemodified = new DateTime(1901, 1, 1);
if (!UInt32.TryParse(rdr.GetValue(7).ToString(), out modifiedby))
modifiedby = 0;
}
}
}
finally
{
if (rdr != null)
rdr.Close();
}
if (conn != null)
{
conn.Close();
}
_gloID = gloid;
_Username = username;
_Password = password;
_Note = note;
_Active = active;
_Status = status;
_gvoID = gvoid;
_DateModified = datemodified;
_ModifiedBy = modifiedby;
}
示例4: Advertisement
public Advertisement(OleDbDataReader reader)
{
this.StrId = reader.GetString(0);
if (!reader.IsDBNull(1))
this.IntType = reader.GetInt32(1);
else
this.IntType = 3;
if (!reader.IsDBNull(2))
this.StrContent = reader.GetString(2);
else
this.StrContent = "";
}
示例5: Form_Update
public Form_Update(OleDbDataReader oddr)
{
InitializeComponent();
connector = new DBconnector();
while (oddr.Read())
{
tb_Name.Text = oddr.GetString(0);
tb_Desc.Text = oddr.GetString(2);
tb_Seq.Text = oddr.GetString(3);
}
}
示例6: Form1
public Form1()
{
InitializeComponent();
PC.list = new List<PC>();
PC.total = new List<PC>();
data.Columns.Add("Id", "Id");
data.Columns.Add("PC", "PC");
data.Columns.Add("Inicio", "Inicio");
data.Columns.Add("Tiempo", "Tiempo");
data.Columns.Add("Total", "Total");
data.Columns[3].Width = 130;
data.Columns[3].Width = 130;
r = MSAConnection.read("select * from item");
while (r.Read())
{
String d = "";
PC p = new PC();
p.id = r.GetInt32(0);
p.precio = r.GetInt32(2);
if (!r.IsDBNull(3))
{
//d = r.GetDateTime(3).ToString();
DateTime x = r.GetDateTime(3);
d = x.Hour + ":" + x.Minute + ":" + x.Second;
p.inicio = r.GetDateTime(3);
PC.list.Add(p);
}
PC.total.Add(p);
data.Rows.Add(r.GetInt32(0), r.GetString(1), d);
}
// MessageBox.Show(PC.total.Count + "");
thetimer.Start();
}
示例7: Coupon
public Coupon(OleDbDataReader reader)
{
this.StrId = reader.GetString(0);
if (!reader.IsDBNull(1))
this.StrSmallImg = reader.GetString(1);
else
this.strSmallImg = "";
if (!reader.IsDBNull(2))
this.StrLargeImg = reader.GetString(2);
else
this.StrLargeImg = "";
if (!reader.IsDBNull(3))
this.StrPrintImg = reader.GetString(3);
else
this.StrPrintImg = "";
}
示例8: consultaUmLivro
public static void consultaUmLivro()
{
String aux = "select * from TabLivro where codigo ='" + Livro.getCodigo() + "'";
conecta();
strSQL = new OleDbCommand(aux, conn);
result = strSQL.ExecuteReader();
Erro.setErro(false);
if (result.Read())
{
Livro.setTitulo(result.GetString(1));
Livro.setAutor(result.GetString(2));
Livro.setEditora(result.GetString(3));
Livro.setAno(result.GetString(4));
}
else
Erro.setMsg("Livro não cadastrado.");
desconecta();
}
示例9: ValidarUtilizador
//
// Validar o Utilizador que se ligou ao servidor
// nome: O Nome de Utilizador
// pass: Password
//
// Retorna: true se o utilizador foi encontrado na Base de Dados e se a password estava correcta
// false se o utilizador não existe ou a password estava incorrecta
//
public bool ValidarUtilizador(String nome, String pass)
{
try
{
OleDbCommand cmdSQL = LigacaoBD.CreateCommand();
cmdSQL.CommandText = "SELECT * FROM tabela_utilizadores_src";
LeitorBD = cmdSQL.ExecuteReader();
while (LeitorBD.Read())
{
if (LeitorBD.GetString(0) == nome && LeitorBD.GetString(1) == pass)
{
return true;
}
}
}
catch (OleDbException) { }
return false;
}
示例10: Kontaktdaten
public Kontaktdaten()
{
InitializeComponent();
try
{
dBVerbindung = new OleDbConnection(verbindungsstring);
dBVerbindung.Open();
offen = true;
befehl = dBVerbindung.CreateCommand();
//Übersicht (DataGHridView) anzeigen
befehl.CommandText = "select * from Kontakte;";
datenleser = befehl.ExecuteReader();
int row = 0;
while (datenleser.Read())
{
//leere zeile hinzufügen
string[] row_init = { "", "", "", "", "" };
dataGridViewKontakte.Rows.Add(row_init);
//GridView füllen
dataGridViewKontakte.Rows[row].Cells[0].Value = datenleser.GetInt32(0).ToString();
dataGridViewKontakte.Rows[row].Cells[1].Value = datenleser.GetString(1);
dataGridViewKontakte.Rows[row].Cells[2].Value = datenleser.GetString(2);
dataGridViewKontakte.Rows[row].Cells[3].Value = datenleser.GetString(3);
dataGridViewKontakte.Rows[row].Cells[4].Value = datenleser.GetString(4);
dataGridViewKontakte.Rows[row].Cells[5].Value = datenleser.GetString(5);
row = row + 1;
}
}
catch (Exception ausnahme)
{
MessageBox.Show("Datenbankfehler: " + ausnahme.Message);
}
finally
{
if (offen == true) dBVerbindung.Close();
}
}
示例11: Load
public static void Load(this DataObject dataObj, OleDbDataReader reader)
{
try
{
foreach (ColumnDefinition columnDef in dataObj.ColumnDefs())
{
if (reader.GetValue(columnDef.ColumnIndex) != DBNull.Value)
{
switch (columnDef.ColumnFieldType)
{
case ColumnDefinition.FieldType.String:
dataObj.GetColumnValues()[columnDef.ColumnIndex] = reader.GetString(columnDef.ColumnIndex);
break;
case ColumnDefinition.FieldType.Int32:
dataObj.GetColumnValues()[columnDef.ColumnIndex] = reader.GetInt32(columnDef.ColumnIndex);
break;
case ColumnDefinition.FieldType.Boolean:
dataObj.GetColumnValues()[columnDef.ColumnIndex] = reader.GetBoolean(columnDef.ColumnIndex);
break;
}
}
else //default values for nulls
{
switch (columnDef.ColumnFieldType)
{
case ColumnDefinition.FieldType.String:
dataObj.GetColumnValues()[columnDef.ColumnIndex] = string.Empty;
break;
case ColumnDefinition.FieldType.Int32:
dataObj.GetColumnValues()[columnDef.ColumnIndex] = 0;
break;
case ColumnDefinition.FieldType.Boolean:
dataObj.GetColumnValues()[columnDef.ColumnIndex] = false;
break;
}
}
}
}
catch (Exception e)
{
//TODO: what to do here?
}
}
示例12: vQualification
// Constructor for searched volunteer qualification
public vQualification(uint gvqid)
{
// Declarations
uint gvoid = 0;
string qualification = null;
// Command
string query = string.Format("SELECT gvo_id, gvq_qual " +
"FROM gfrc_volunteer_qualification WHERE gvq_id = {0}", gvqid);
try
{
using (conn)
{
conn.Open();
cmd = new OleDbCommand(query, conn);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
UInt32.TryParse(rdr.GetValue(0).ToString(), out gvoid);
qualification = rdr.GetString(1);
}
}
}
finally
{
if (rdr != null)
rdr.Close();
}
if (conn != null)
{
conn.Close();
}
_gvqID = gvqid;
_gvoID = gvoid;
_Qualification = qualification;
}
示例13: ExecutaComando
public String ExecutaComando(string comandoSql)
{
StringBuilder lido = new StringBuilder();
cmd.CommandText = comandoSql;
try
{
using (leitor = cmd.ExecuteReader())
{
while (leitor.Read())
{
lido.Append(leitor.GetString(0));
}
}
}
finally
{
if (leitor != null)
leitor.Close();
}
return lido.ToString();
}
示例14: getFoodList
internal static List<FoodList> getFoodList()
{
List<FoodList> fl = new List<FoodList>();
try
{
cmd = new OleDbCommand("SELECT ID, FoodName, FoodPrice, FoodType FROM FoodList ORDER BY FoodName;", conn);
reader = cmd.ExecuteReader();
while (reader.Read())
{
FoodList fudList = new FoodList(reader.GetInt32(0).ToString(), reader.GetString(1), reader.GetInt32(2), reader.GetString(3));
fl.Add(fudList);
}
}
catch (Exception ee)
{
reader.Close();
MessageBox.Show("getFoodList() error: " + ee.ToString());
}
reader.Close();
return fl;
}
示例15: listQualifications
public Vector<vQualification> listQualifications(uint gvoid)
{
// Declarations
Vector<vQualification> quals = new Vector<vQualification>();
uint gvqid = 0;
string qualification = null;
vQualification input = new vQualification();
// Command
string query = string.Format("SELECT gvq_id, gvq_qual " +
"FROM gfrc_volunteer_qualification WHERE gvo_id = {0}", gvoid);
try
{
using (conn)
{
conn.Open();
cmd = new OleDbCommand(query, conn);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
if (!UInt32.TryParse(rdr.GetValue(0).ToString(), out gvqid))
gvqid = 0;
qualification = rdr.GetString(1);
if (gvqid != 0)
{
input = new vQualification(gvqid, gvoid, qualification);
quals.Add(input);
}
}
}
}
finally
{
if (rdr != null)
rdr.Close();
}
if (conn != null)
{
conn.Close();
}
return quals;
}