本文整理汇总了C#中OracleDataAdapter类的典型用法代码示例。如果您正苦于以下问题:C# OracleDataAdapter类的具体用法?C# OracleDataAdapter怎么用?C# OracleDataAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OracleDataAdapter类属于命名空间,在下文中一共展示了OracleDataAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PesquisarButton_Click
private void PesquisarButton_Click(object sender, EventArgs e)
{
StringBuilder sbQuery = new StringBuilder();
sbQuery.Append(query);
try
{
if (!FiltroTextBox.Text.Equals("") && !FiltroComboBox.SelectedItem.ToString().Equals("FORNECEDOR"))
{
sbQuery.Append(" WHERE " + FiltroComboBox.SelectedItem.ToString() + " = " + FiltroTextBox.Text);
}
if (!FiltroTextBox.Text.Equals("") && FiltroComboBox.SelectedItem.ToString().Equals("FORNECEDOR"))
{
sbQuery.Append(" WHERE " + FiltroComboBox.SelectedItem.ToString() + " like '%" + FiltroTextBox.Text + "%'");
}
OracleDataAdapter adpBuscarDados = new OracleDataAdapter(sbQuery.ToString(), conn);
DataTable resultado = new DataTable();
adpBuscarDados.Fill(resultado);
GridPesquisa.DataSource = resultado;
sbQuery.Clear();
}
catch (OracleException)
{
}
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string ab = Session["B_c_package"].ToString();
string cmdQuery = "Select * from Decuration_Package where dec_pack_service = '"+ ab +"' ";
OracleDataAdapter a = new OracleDataAdapter(cmdQuery, ConnectionString);
OracleCommandBuilder builder = new OracleCommandBuilder(a);
DataSet ds = new DataSet();
a.Fill(ds, "Decuration_Package");
foreach (DataRow r in ds.Tables["Decuration_Package"].Rows)
{
ListItem i = new ListItem();
i.Text = r["DEC_PACK_NAME"].ToString();
i.Value = r["DEC_PACK_ID"].ToString();
Session["Decuration_price"]= r["DEC_PACK_PRICE"].ToString();
DropDownList_decuration.Items.Add(i);
}
string cmdQuery2 = "Select * from FOOD_PACKAGE where f_pack_service = '" + ab + "' ";
OracleDataAdapter b = new OracleDataAdapter(cmdQuery2, ConnectionString);
OracleCommandBuilder builder2 = new OracleCommandBuilder(b);
DataSet ds2 = new DataSet();
b.Fill(ds2, "FOOD_PACKAGEes");
foreach (DataRow r in ds2.Tables["FOOD_PACKAGEes"].Rows)
{
ListItem i = new ListItem();
i.Text = r["f_pack_name"].ToString();
i.Value = r["f_pack_id"].ToString();
Session["FOOD_price"] = r["f_pack_price"].ToString();
DropDownList_food_package.Items.Add(i);
}
}
}
示例3: button1_Click
private void button1_Click(object sender, EventArgs e)
{
OracleConnection conn = new OracleConnection();
conn.ConnectionString = "User ID=SYSTEM; Password=19; Data Source=PC";
try
{
conn.Open();
MessageBox.Show("Veritabanına Baglantı Basarılı.");
}
catch
{
MessageBox.Show("Veritabanına Baglanılamadı.");
}
OracleCommand cmd = new OracleCommand();
cmd.CommandText = "SELECT ogrenci_tablosu.ogrenci_ad, fakulte_tablosu.fakulte_ad FROM ogrenci_tablosu, bolum_tablosu, fakulte_tablosu WHERE ogrenci_tablosu.ogrenci_bolum = bolum_tablosu.bolum_id AND bolum_tablosu.bolum_fakulte = fakulte_tablosu.fakulte_id";
cmd.Connection = conn;
OracleDataAdapter adapter = new OracleDataAdapter();
adapter.SelectCommand = cmd;
DataSet dataset = new DataSet();
adapter.Fill(dataset);
dataGridView1.DataSource = dataset.Tables[0];
conn.Close();
}
示例4: ReadDataToDataSet
/// <summary>
/// 将数据读取到 DataSet 中.
/// </summary>
public void ReadDataToDataSet()
{
Console.WriteLine("使用DataAdapter,将数据填充到DataSet中,然后脱离数据库,直接对DataSet进行处理。");
// 建立数据库连接.
OracleConnection conn = new OracleConnection(connString);
// 创建一个适配器
OracleDataAdapter adapter = new OracleDataAdapter(SQL, conn);
// 创建DataSet,用于存储数据.
DataSet testDataSet = new DataSet();
// 执行查询,并将数据导入DataSet.
adapter.Fill(testDataSet, "result_data");
// 关闭数据库连接.
conn.Close();
// 处理DataSet中的每一行数据.
foreach (DataRow testRow in testDataSet.Tables["result_data"].Rows)
{
// 将检索出来的数据,输出到屏幕上.
Console.WriteLine("NO:{0} ; Date:{1} ; Money:{2} ",
testRow["NO"], testRow["SALE_DATE"], testRow["SUM_MONEY"]
);
}
}
示例5: GetItensEstoque
public static DataTable GetItensEstoque()
{
DataTable dt = new DataTable();
OracleDataAdapter da = new OracleDataAdapter();
OracleConnection conn = Conexao.GetInstance();
OracleCommand cmd = new OracleCommand();
try
{
cmd.CommandText = "SELECT * FROM ITEM_ESTOQUE ";
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
da.SelectCommand = cmd;
da.Fill(dt);
return dt;
}
catch (Exception ex)
{
strErrMsg = "Atenção, o sistema detectou o seguinte problema: " + "\r\n" +
"Descrição: " + Convert.ToString(ex.Message) + "\r\n" +
"Origem: " + Convert.ToString(ex.Source);
MessageBox.Show(strErrMsg, "Procedimento: " + Convert.ToString(ex.TargetSite),
MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
}
示例6: MedStoreLoad
void MedStoreLoad()
{
try
{
conn.Open();
string sqlquery = "SELECT * FROM MED_STORE";
//string sqlquery = "SELECT * FROM MED_INFO";
OracleCommand cmd = new OracleCommand(sqlquery, conn);
OracleDataAdapter oda = new OracleDataAdapter();
oda.SelectCommand = cmd;
dt = new DataTable();
// dt.Columns["MED_NAME"].ColumnName = "Name";
oda.Fill(dt);
BindingSource bsource = new BindingSource();
bsource.DataSource = dt;
dataGridView1.DataSource = bsource;
oda.Update(dt);
dt.Columns[0].ColumnName = "ID";
dt.Columns[1].ColumnName = "Name";
dt.Columns[2].ColumnName = "Quantity";
dt.Columns[3].ColumnName = "Damage Qty";
dt.Columns[4].ColumnName = "Reorder Level";
dt.AcceptChanges();
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例7: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Global.CurrentPerson == null)
Response.Redirect("Index.aspx");
DataTable seasonsTable = new DataTable();
List<Season> seasons = new List<Season>();
using (OracleConnection objConn = new OracleConnection(Global.ConnectionString))
{
// Set up the seasons command
var seasonsCommand = new OracleCommand("TICKETS_QUERIES.getSeasonsForPurchase", objConn) { BindByName = true, CommandType = CommandType.StoredProcedure };
seasonsCommand.Parameters.Add("p_Return", OracleDbType.RefCursor, ParameterDirection.ReturnValue);
seasonsCommand.Parameters.Add("p_PersonId", OracleDbType.Int64, Global.CurrentPerson.person_id, ParameterDirection.Input);
try
{
// Execute the queries and auto map the results to models
objConn.Open();
var seasonsAdapter = new OracleDataAdapter(seasonsCommand);
seasonsAdapter.Fill(seasonsTable);
seasons = Mapper.DynamicMap<IDataReader, List<Season>>(seasonsTable.CreateDataReader());
}
catch (Exception)
{
Response.Redirect("Index.aspx");
}
objConn.Close();
}
// Fill list dropdowns with data from the database
if (seasons.Count > 0)
{
var seasonsWithEvents = seasons.GroupBy(s => s.season_id).Select(season => new Season()
{
season_id = season.First().season_id,
name = season.First().name,
price = season.First().price,
ticket_count = season.First().ticket_count,
event_names = seasons.Where(ev => ev.season_id == season.First().season_id).Select(en => en.event_name).ToList()
}).ToList();
SeasonDropDown.DataTextField = "name";
SeasonDropDown.DataValueField = "season_id";
SeasonDropDown.DataSource = seasonsWithEvents;
SeasonDropDown.DataBind();
SeasonListView.DataSource = seasonsWithEvents;
SeasonListView.DataBind();
}
if (Request.QueryString["Success"] != null)
{
Error.Text = "Successfully purchased season ticket!";
Error.Visible = true;
}
}
}
示例8: GetProdOCRData
public DataSet GetProdOCRData(string queryName,string startDate, string endDate)
{
string queryPath = string.Format(@"{0}\Query\{1}", Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),queryName);
string query = File.ReadAllText(queryPath);
query = string.Format(query, startDate, endDate);
DataSet ds = new DataSet();
using (oraconnection = new OracleConnection(ConfigurationManager.AppSettings["DSN_PNRP"]))
{
try
{
oraconnection.Open();
oracommand = new OracleCommand(query, oraconnection);
oracommand.CommandType = CommandType.Text;
OracleDataAdapter adp = new OracleDataAdapter(oracommand);
ds = new DataSet();
adp.Fill(ds);
}
catch (Exception)
{
}
finally
{
oraconnection.Close();
}
return ds;
}
}
示例9: LoginRandomEmployee
private void LoginRandomEmployee()
{
DataTable employeeTable = new DataTable();
Person employee = null;
using (OracleConnection objConn = new OracleConnection(Global.ConnectionString))
{
OracleCommand objCmd = new OracleCommand("TICKETS_QUERIES.getRandomEmployee", objConn) { BindByName = true, CommandType = CommandType.StoredProcedure };
objCmd.Parameters.Add("p_Return", OracleDbType.RefCursor, ParameterDirection.ReturnValue);
try
{
objConn.Open();
OracleDataAdapter adapter = new OracleDataAdapter(objCmd);
adapter.Fill(employeeTable);
employee = Mapper.DynamicMap<IDataReader, List<Person>>(employeeTable.CreateDataReader()).FirstOrDefault();
}
catch (Exception)
{
Response.Redirect("../Default.aspx");
}
objConn.Close();
}
if (employee != null)
{
Global.CurrentPerson = employee;
Global.CurrentPerson.accountType = Account.Faculty;
}
else
Response.Redirect("../Default.aspx");
}
示例10: ChiTietDuAn
public DataTable ChiTietDuAn(string mdv, string nsd, string pas, string maDonVi, long idDuAn)
{
try
{
ConnectDB.CloseConnection(_connectGs);
_connectGs = new OracleConnection();
_connectGs = ConnectDB.GetOracleConnection(_connectGs);
var cm = _connectGs.CreateCommand();
cm.CommandText = "usp_ChiTiet_DuAn";
cm.CommandType = CommandType.StoredProcedure;
cm.Parameters.Add(new OracleParameter("ma_donvi", OracleDbType.Varchar2)).Value = "";
cm.Parameters.Add(new OracleParameter("nsd", OracleDbType.Varchar2)).Value = "";
cm.Parameters.Add(new OracleParameter("pas", OracleDbType.Varchar2)).Value = "";
cm.Parameters.Add(new OracleParameter("id_duan", OracleDbType.Long)).Value = idDuAn;
cm.Parameters.Add(new OracleParameter("ma_donvi_thuchien", OracleDbType.Varchar2)).Value = maDonVi;
cm.Parameters.Add(new OracleParameter("cs_lke", OracleDbType.RefCursor)).Direction =
ParameterDirection.Output;
var tableGs = new DataTable();
_oracleAdapter = new OracleDataAdapter(cm);
_oracleAdapter.Fill(tableGs);
return tableGs;
}
catch (Exception)
{
return null;
}
finally
{
ConnectDB.CloseConnection(_connectGs);
}
}
示例11: addPersonToGroup
private GroupRequest addPersonToGroup(int personId, int seriesId)
{
DataTable groupTable = new DataTable();
GroupRequest groupResult = new GroupRequest();
using (OracleConnection objConn = new OracleConnection(Global.ConnectionString))
{
// Set up the searchPeople command
var command = new OracleCommand("TICKETS_API.insertGroupRequests", objConn) { BindByName = true, CommandType = CommandType.StoredProcedure };
command.Parameters.Add("p_Return", OracleDbType.RefCursor, ParameterDirection.ReturnValue);
command.Parameters.Add("p_PersonId", OracleDbType.Int64, Global.CurrentPerson.person_id, ParameterDirection.Input);
command.Parameters.Add("p_RequestedId", OracleDbType.Int64, personId, ParameterDirection.Input);
command.Parameters.Add("p_SeriesId", OracleDbType.Int64, seriesId, ParameterDirection.Input);
// Execute the query and map the results to models
objConn.Open();
var groupAdapter = new OracleDataAdapter(command);
groupAdapter.Fill(groupTable);
groupResult.group_id = long.Parse(groupTable.Rows[0]["group_id"].ToString());
groupResult.requested_id = long.Parse(groupTable.Rows[0]["requested_id"].ToString());
groupResult.requested_firstname = groupTable.Rows[0]["requested_firstname"].ToString();
groupResult.requested_lastname = groupTable.Rows[0]["requested_lastname"].ToString();
objConn.Close();
}
return groupResult;
}
示例12: btn_hyouji_Click
private void btn_hyouji_Click(object sender, EventArgs e)
{
try
{
dt.Rows.Clear();
dt.Columns.Clear();
dt.Clear();
TssSystemLibrary tssdb = new TssSystemLibrary();
string connStr = tssdb.GetConnectionString();
OracleConnection conn = new OracleConnection(connStr);
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
string sql = "select * from " + cb_table_name.Text;
if (tb_sql.Text.Length >= 1)
{
sql = sql + " " + tb_sql.Text;
}
cmd.CommandText = sql;
da = new OracleDataAdapter(cmd);
cb = new OracleCommandBuilder(da);
das = new DataSet();
da.Fill(dt);
dgv_table.DataSource = null;
dgv_table.DataSource = dt;
}
catch
{
dgv_table.DataSource = null;
}
}
示例13: DLookUp
public object DLookUp(String column, string table, string condition)
{
OracleConnection objConexion = default(OracleConnection);
OracleDataAdapter objComando = default(OracleDataAdapter);
DataSet requestquery = new DataSet();
object result = null;
objConexion = new OracleConnection(driver);
objConexion.Open();
if (string.IsNullOrEmpty(condition))
{
objComando = new OracleDataAdapter("Select " + column + " from " + table, objConexion);
}
else
{
objComando = new OracleDataAdapter("Select " + column + " from " + table + " where " + condition, objConexion);
}
objComando.Fill(requestquery);
try
{
result = requestquery.Tables[0].Rows[0][requestquery.Tables[0].Columns.IndexOf(column)];
}
catch (Exception ex)
{
result = -1;
}
objConexion.Close();
return result;
}
示例14: changeChartView
private void changeChartView()
{
using (OracleConnection connection = new OracleConnection(FormLogin.connString))
{
connection.Open();
String query = "SELECT m.idRound AS ROUND, ROUND(SUM(part.match_Rating)/COUNT(part.match_Rating)) AS TEAMRATING"
+ " FROM participates part JOIN player p ON (part.idPlayer = p.idPlayer) JOIN match m ON (part.idMatch = m.idMatch)"
+ " WHERE p.idTeam = " + Team.Id
+ " GROUP BY m.idRound"
+ " ORDER BY m.idRound";
OracleDataAdapter adapter = new OracleDataAdapter(query, connection);
DataTable table = new DataTable();
adapter.Fill(table);
chartTeamRating.DataSource = table;
chartTeamRating.Series["Series1"].XValueMember = "Round";
chartTeamRating.Series["Series1"].YValueMembers = "TeamRating";
}
chartTeamRating.ChartAreas["ChartArea1"].AxisX.Title = "Rounds";
chartTeamRating.ChartAreas["ChartArea1"].AxisY.Title = "Rating";
chartTeamRating.ChartAreas["ChartArea1"].AxisX.Minimum = 1;
chartTeamRating.ChartAreas["ChartArea1"].AxisX.Maximum = 38;
chartTeamRating.ChartAreas["ChartArea1"].AxisX.Interval = 1;
chartTeamRating.ChartAreas["ChartArea1"].AxisY.Minimum = 1000;
chartTeamRating.ChartAreas["ChartArea1"].AxisY.Maximum = 3000;
chartTeamRating.ChartAreas["ChartArea1"].Visible = true;
chartTeamRating.Series["Series1"].BorderWidth = 3;
}
示例15: setDataGrid
private void setDataGrid()
{
DataTable table = new DataTable();
using (OracleConnection connection = new OracleConnection(FormLogin.connString))
{
String query = "SELECT c.description as Tip, c.value as Coefficient, r.homeTeam as HomeTeam, r.goalshome || ' - ' || r.goalsguest as Result, r.guestteam as GuestTeam"
+ " FROM Computegain c JOIN Results r ON (c.idMatch = r.idMatch) WHERE c.idTipster = "+idTipster;
OracleDataAdapter adapter = new OracleDataAdapter(query, connection);
adapter.Fill(table);
}
dataGrid.DataSource = table;
dataGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dataGrid.AutoSize = true;
dataGrid.DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
dataGrid.Columns["Tip"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight;
dataGrid.Columns["HomeTeam"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight;
dataGrid.Columns["GuestTeam"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomLeft;
dataGrid.Columns["GuestTeam"].HeaderText = "Guest Team";
dataGrid.Columns["HomeTeam"].HeaderText = "Home Team";
dataGrid.Columns["Tip"].HeaderText = "Tip";
dataGrid.Columns["Coefficient"].HeaderText = "Coefficient";
dataGrid.Columns["Result"].HeaderText = "Result";
}