本文整理汇总了C#中System.Data.OleDb.OleDbDataReader.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbDataReader.GetValue方法的具体用法?C# OleDbDataReader.GetValue怎么用?C# OleDbDataReader.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.OleDb.OleDbDataReader
的用法示例。
在下文中一共展示了OleDbDataReader.GetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: Holiday
// Constructor for searched volunteer holiday
public Holiday(uint gvhid)
{
// Declarations
uint gvoid = 0, modifiedby = 0;
DateTime datemodified = new DateTime(1901, 1, 1), start = new DateTime(1901, 1, 1), end = new DateTime(1901, 1, 1);
// Command
string query = string.Format("SELECT gvo_id, gvh_start, gvh_end, date_modified, modified_by " +
"FROM gfrc_volunteer_holiday WHERE gvh_id = {0}", gvhid);
try
{
using (conn)
{
conn.Open();
cmd = new OleDbCommand(query, conn);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
gvoid = Convert.ToUInt32(rdr.GetInt32(0));
start = rdr.GetDateTime(1);
if (!DateTime.TryParse(rdr.GetValue(2).ToString(), out end))
end = new DateTime(1901, 1, 1);
if (!DateTime.TryParse(rdr.GetValue(14).ToString(), out datemodified))
datemodified = new DateTime(1901, 1, 1);
if (!UInt32.TryParse(rdr.GetValue(15).ToString(), out modifiedby))
modifiedby = 0;
}
}
}
finally
{
if (rdr != null)
rdr.Close();
}
if (conn != null)
{
conn.Close();
}
_gvhID = gvhid;
_gvoID = gvoid;
_Start = start;
_End = end;
_DateModified = datemodified;
_ModifiedBy = modifiedby;
}
示例3: photos
//Get all pictures from Database and save in a list
public List<byte[]> photos()
{
byte[] aBytes = null;
List<byte[]> pictures = new List<byte[]> {};
for (int i = 1; i <= 5000; i++)
{
try
{
int cont = 0;
string query = "SELECT image FROM Data WHERE counter = " + i + " AND image <> NULL;";
command = new OleDbCommand(query, connection);
reader = command.ExecuteReader();
while (reader.Read())
{
aBytes = (byte[])reader.GetValue(cont);
pictures.Add(aBytes);
cont++;
}
reader.Close();
}
catch (Exception e)
{
////The error message is not displayed to continue with the process.
//MessageBox.Show("I'm so sorry, we cannot get the images.\n" + e);
}
}
return pictures;
}
示例4: btnSave_Click
private void btnSave_Click(object sender, EventArgs e)
{
saveFileDialog1.ShowDialog(); //Se muestra el cuadro de diálogo para guardar
string nombreArchivo = saveFileDialog1.FileName; //Contiene la ruta completa del archivo a guardar
FileStream Holi = new FileStream(nombreArchivo,FileMode.Create);
StreamWriter writer = new StreamWriter(Holi);
consulta = "SELECT * FROM Paquetes WHERE Numero = " + cmbPaquetes.SelectedItem;
cmd = new OleDbCommand(consulta, Con);
Con.Open();
DR = cmd.ExecuteReader();
while (DR.Read())
{
writer.Write("Nº: " + DR.GetValue(0) + "\t"); //Escribe el número de paquete
writer.Write("Costo: $" + DR.GetValue(2) + "\t"); //Escribe el costo
writer.Write("Origen: " + DR.GetValue(3) + "\t"); //Escribe el origen
writer.WriteLine("Destino: " + DR.GetValue(4)); //Escribe el destino
}
Con.Close();
consulta = "SELECT * FROM Movimientos WHERE Paquete = " + cmbPaquetes.SelectedItem;
cmd = new OleDbCommand(consulta, Con);
Con.Open();
DR = cmd.ExecuteReader();
int mov;
while (DR.Read())
{
writer.Write("Fecha: " + DR.GetValue(2) + "\t"); //Añade la fecha
mov = (int)DR.GetValue(3);
writer.WriteLine(QueMov[mov-1]); //Añade el movimiento
}
Con.Close(); //Cierra conexión
writer.Close(); //Cierra Streamwriter
Holi.Close(); //Ciera filestream
//PINCHE IMBÉCIL!!!! .l. (-_-) .l.
}
示例5: loadPictureOfCrossSection
//vykresli obrazok
private void loadPictureOfCrossSection(byte num)
{
string command = "Select h,b,tw,tf,r,d from SECTIONS where csprof_name like '" + combo_text + "'";
string h = "h", b = "b", tw = "tw", tf = "tf", r = "r", d = "d";
dat_reader = dat_conn.getDBReader(command);
dat_reader.Read();
try
{
h = dat_reader.GetValue(0).ToString();
b = dat_reader.GetValue(1).ToString();
tw = dat_reader.GetValue(2).ToString();
tf = dat_reader.GetValue(3).ToString();
r = dat_reader.GetValue(4).ToString();
d = dat_reader.GetValue(5).ToString();
}
catch (FormatException) { MessageBox.Show("Probably wrong selected cross-section."); }
catch (InvalidOperationException) { MessageBox.Show("Probably wrong selected cross-section."); }
switch (num)
{
case 1:
Image image = Image.FromFile(@"prierezy\prier1.jpg");
Bitmap myBitmap = new Bitmap(image, pictureBox1.Width, pictureBox1.Height);
Graphics g = Graphics.FromImage(myBitmap);
Font f_text = new Font("Arial", 14, FontStyle.Bold);
g.DrawString(h, f_text, Brushes.Black, new PointF(2, pictureBox1.Height / 2 + 30));
g.DrawString(d, f_text, Brushes.Black, new PointF(pictureBox1.Width / 8, pictureBox1.Height / 2 + 30));
f_text = new Font("Arial", 16, FontStyle.Bold);
g.DrawString(tw, f_text, Brushes.Black, new PointF(pictureBox1.Width / 2 +50, pictureBox1.Height / 2-30));
g.DrawString(tf, f_text, Brushes.Black, new PointF(pictureBox1.Width/1.15f, pictureBox1.Height/1.25f));
g.DrawString(r, f_text, Brushes.Black, new PointF(pictureBox1.Width / 2 + 80, pictureBox1.Height / 2 + 47));
f_text = new Font("Arial", 19, FontStyle.Bold);
g.DrawString(b, f_text, Brushes.Black, new PointF(pictureBox1.Width / 2 + 12, 10));
//g.DrawImage(myBitmap, AutoScrollPosition.X, AutoScrollPosition.Y);
pictureBox1.Image = myBitmap;
break;
case 2:
image = Image.FromFile(@"prierezy\prier2.jpg");
myBitmap = new Bitmap(image, pictureBox1.Width, pictureBox1.Height);
g = Graphics.FromImage(myBitmap);
f_text = new Font("Arial", 14, FontStyle.Bold);
g.DrawString(h, f_text, Brushes.Black, new PointF(2, pictureBox1.Height / 2 + 30));
f_text = new Font("Arial", 16, FontStyle.Bold);
g.DrawString(b, f_text, Brushes.Black, new PointF(pictureBox1.Width / 2 + 10, 12));
//g.DrawString(tw, f_text, Brushes.Black, new PointF(10, 0));
//g.DrawString(tf, f_text, Brushes.Black, new PointF(10, 0));
//g.DrawString(r, f_text, Brushes.Black, new PointF(10, 0));
//g.DrawString(d, f_text, Brushes.Black, new PointF(10, 0));
//g.DrawImage(myBitmap, AutoScrollPosition.X, AutoScrollPosition.Y);
pictureBox1.Image = myBitmap;
break;
case 3: break;
default: MessageBox.Show("Neimplementovane..."); break;
}
}
示例6: GetDataFieldValues
public static string GetDataFieldValues(OleDbDataReader reader)
{
string dt = "";
for (int i = 0; i < reader.FieldCount; i++)
{
dt = dt + "'" + ReplaceMarks(reader.GetValue(i).ToString()) + "'";
if (i < reader.FieldCount - 1)
{
dt = dt + ", ";
}
}
return dt;
}
示例7: 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);
}
}
}
示例8: 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?
}
}
示例9: LastRequest
//Get the last request in the data base
public int LastRequest()
{
int last = 1;
string query = "SELECT MAX(counter) FROM Data";
try
{
command = new OleDbCommand(query, connection);
reader = command.ExecuteReader();
if(reader.Read())
{
last = int.Parse(reader.GetValue(0).ToString());
}
reader.Close();
}
catch(Exception e)
{
MessageBox.Show("We're so sorry, couldn't get the last record." + e);
}
return last;
}
示例10: loadList
//loading of data
//data from mat_name from table CONCRETE in database
//loading all elements from column mat_num except 0,1,List_name,Unit
private void loadList()
{
string item;
listView1.Items.Clear();
dat_reader = dat_conn.getDBReader("Select mat_name from concrete where id_concrete not in (1,2,3) order by id_concrete"); // if cell type is text - string '2'
while (dat_reader.Read())
{
item = dat_reader.GetValue(0).ToString();
listView1.Items.Add(item);
}
/*
ListViewItem();
listView1.Items.Add();
ListViewItem.ListViewSubItem
ListViewGroupCollection
ListViewItem.ListViewSubItemCollection ();
*/
}
示例11: 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;
}
示例12: createQualification
public bool createQualification(vQualification create)
{
bool result = false;
// Command
string query = String.Format(@"INSERT INTO gfrc_volunteer_qualification (gvo_id, gvq_qual) " +
"VALUES({0}, '{1}')",
create.gvoID, create.Qualification);
int affected = 0;
try
{
using (conn)
{
conn.Open();
cmd = new OleDbCommand(query, conn);
affected = cmd.ExecuteNonQuery();
// checks if rows were affected by the insert query
if (affected > 0)
{
result = true;
query = String.Format(@"SELECT gvq_id FROM gfrc_volunteer_qualification WHERE gvq_id = (SELECT MAX(gvq_id) FROM gfrc_volunteer_qualification)");
cmd = new OleDbCommand(query, conn);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
// Set gloID
UInt32.TryParse(rdr.GetValue(0).ToString(), out _gvqID);
}
}
}
}
catch (Exception e)
{
result = false;
}
finally
{
if (rdr != null)
rdr.Close();
}
if (conn != null)
{
conn.Close();
}
return result;
}
示例13: 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;
}
示例14: CreateFacetCategory
private PivotFacetCategory CreateFacetCategory(OleDbDataReader dataReader)
{
String name = null;
PivotFacetType type = null;
for (int column = 0; column < dataReader.FieldCount; column++)
{
if (dataReader.IsDBNull(column)) continue;
String columnName = dataReader.GetName(column).ToLowerInvariant();
String value = dataReader.GetValue(column).ToString();
if (columnName == OleDbSchemaConstants.FacetCategory.Name)
{
name = value;
}
else if (columnName == OleDbSchemaConstants.FacetCategory.Type)
{
type = PivotFacetType.Parse(value);
}
}
if (name == null) throw new InvalidDataException("Facet Categories data set is missing a Name column");
if (type == null) throw new InvalidDataException("Facet Categories data set is missing a Type column");
return new PivotFacetCategory(name, type);
}
示例15: ReadItem
private PivotItem ReadItem(OleDbDataReader dataReader, int rowId)
{
PivotItem item = new PivotItem(rowId.ToString(), this);
for (int column = 0; column < dataReader.FieldCount; column++)
{
if (dataReader.IsDBNull(column)) continue;
String columnName = dataReader.GetName(column).ToLowerInvariant();
String value = dataReader.GetValue(column).ToString();
if (String.IsNullOrEmpty(value)) continue;
if (columnName == OleDbSchemaConstants.Item.Name)
{
item.Name = value;
}
else if (columnName == OleDbSchemaConstants.Item.Image)
{
String imagePath = UriUtility.ExpandRelativeUri(this.BasePath, value);
item.Image = new PivotImage(imagePath);
}
else if (columnName == OleDbSchemaConstants.Item.Description)
{
item.Description = value;
}
else if (columnName == OleDbSchemaConstants.Item.Href)
{
item.Href = value;
}
else if (columnName == OleDbSchemaConstants.Item.RelatedLinks)
{
StringReader valueReader = new StringReader(value);
String singleValue = null;
while ((singleValue = valueReader.ReadLine()) != null)
{
String[] parts = singleValue.Split(
new String[] { OleDbSchemaConstants.LinkPartDelimiter }, StringSplitOptions.None);
if (parts.Length > 0)
{
String name = null, url = null;
if (parts.Length == 1)
{
url = parts[0];
}
else if (parts.Length >= 2)
{
name = parts[0];
url = parts[1];
}
item.AddRelatedLink(new PivotLink(name, url));
}
}
}
else
{
PivotFacetCategory facetCategory = null;
foreach (PivotFacetCategory currentFacetCategory in m_facetCategoryMap.Values)
{
if (columnName == currentFacetCategory.Name.Replace('.', '#').ToLowerInvariant())
{
facetCategory = currentFacetCategory;
break;
}
}
if (facetCategory != null)
{
item.AddFacetValues(facetCategory.Name, this.SplitJoinedStrings(value).ToArray());
}
}
}
return item;
}