当前位置: 首页>>代码示例>>C#>>正文


C# OleDbDataAdapter.Update方法代码示例

本文整理汇总了C#中System.Data.OleDb.OleDbDataAdapter.Update方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbDataAdapter.Update方法的具体用法?C# OleDbDataAdapter.Update怎么用?C# OleDbDataAdapter.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.OleDb.OleDbDataAdapter的用法示例。


在下文中一共展示了OleDbDataAdapter.Update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: searcher

        public void searcher(string field, string column)
        {
            try
            {

                connectionString = ConfigurationManager.AppSettings["DBConnectionString"] + frmHomeScreen.mUserFile;
                string query = "select ISBN, Title, Author, Publisher, Binding, pub_date as Publication_Date, Pages, Available from book where " + column + " like '%" + escapeHandling(field) + "%' order by Author, Title;";

                OleDbDataAdapter da = new OleDbDataAdapter(query, connectionString);
                OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
                DataTable dt = new DataTable();

                da.Fill(dt);

                BindingSource bs = new BindingSource();
                bs.DataSource = dt;

                dgvBook.DataSource = bs;

                da.Update(dt);

                databaseHandler d = new databaseHandler();
                d.closeDatabaseConnection();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }

            dgvBook.ClearSelection();
        }
开发者ID:jetpacktuxedo,项目名称:library,代码行数:31,代码来源:frmViewBooks.cs

示例2: Button3_Click

    protected void Button3_Click(object sender, EventArgs e)
    {
        if (this.IsValid)
        {
            string con = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Web.HttpContext.Current.Server.MapPath("App_data/db1.mdb");
            OleDbConnection ole = new OleDbConnection(con);
            DataSet ds = new DataSet();
            DataRow drow;
            ole.Open();
            OleDbDataAdapter oda = new OleDbDataAdapter("select * from yonghu", con);
            OleDbCommandBuilder ob = new OleDbCommandBuilder(oda);
            oda.Fill(ds, "tab");
            int num = ds.Tables["tab"].Rows.Count;
            drow = ds.Tables["tab"].NewRow();
            drow[0] = num + 1;
            num++;
            drow[1] = TextBox2.Text;
            drow[2] = TextBox3.Text;
            ds.Tables["tab"].Rows.Add(drow);
            oda.Update(ds, "tab");
            ole.Close();
            this.Panel3.Visible = false;
            this.Label2.Visible = true;
            this.Label3.Visible = true;
            this.Button4.Visible = true;

        }
    }
开发者ID:VivianWalker,项目名称:vivianwalker.github.com,代码行数:28,代码来源:zhuce.aspx.cs

示例3: Delete

        /// <summary>Delete the specified Cause from the specified Issue.</summary>
        /// <param name="pIssueID">ID of the Issue the cause applies to.</param>
        /// <param name="pCauseID">ID of the Cause to delete.</param>
        /// <returns>ID of the modified/created cause row.</returns>
        public void Delete(int pIssueID, int pCauseID)
        {
            try
            {
                using(OleDbDataAdapter oDA		= new OleDbDataAdapter(String.Format("Select * from Causes where issue_id = {0} and cause_id = {1} order by cause_seq", pIssueID, pCauseID), this.DataObject.ConnectionString))
                using(OleDbCommandBuilder oCB = new OleDbCommandBuilder(oDA))
                using(OleDbConnection oConn		= new OleDbConnection(this.DataObject.ConnectionString))
                {
                    // Get the list of previously saved Causes to the current Issue.
                    oConn.Open();
                    DataSet oDS = new DataSet("Causes");
                    oDA.Fill(oDS);

                    // If we found any...And we're updating an existing Cause...
                    if(oDS.Tables[0].Rows.Count > 0)
                    {
                        DataRow oRow = oDS.Tables[0].Rows[0];
                        oRow.Delete();
                        oDA.Update(oDS);
                    }
                }
            }
            catch(Exception e)
            {
                throw new Exception("Unable to save new Issue Cause!\nError: " + e.Message);
            }
        }
开发者ID:pnoverstreet,项目名称:Gnosis,代码行数:31,代码来源:CIssueCause.cs

示例4: frmWhatMedia_Load

        private void frmWhatMedia_Load(object sender, EventArgs e)
        {
            try
            {
                string connectionString = ConfigurationManager.AppSettings["DBConnectionString"] + frmHomeScreen.mUserFile;
                string query = "select Title, isbn as Checkout_Code from (select title, isbn from book union select title, upc from movie union select title,upc from game union select album,upc from cd) order by title;";

                OleDbDataAdapter da = new OleDbDataAdapter(query, connectionString);
                OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
                DataTable dt = new DataTable();

                da.Fill(dt);

                BindingSource bs = new BindingSource();
                bs.DataSource = dt;

                dgvMedia.DataSource = bs;

                da.Update(dt);

                databaseHandler d = new databaseHandler();
                d.closeDatabaseConnection();

                DataGridViewColumn c = dgvMedia.Columns[0];
                c.Width = 155;
                dgvMedia.ClearSelection();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }
开发者ID:jetpacktuxedo,项目名称:library,代码行数:32,代码来源:frmFindMedia.cs

示例5: clears

        private void clears()
        {
            txtNameSearch.Text = "Enter all or part of a name here...";
            txtCCSearch.Text = "Scan a customer card here...";

            try
            {
                connectionString = ConfigurationManager.AppSettings["DBConnectionString"] + frmHomeScreen.mUserFile;
                string query = "select * from customer order by last_name;";

                OleDbDataAdapter da = new OleDbDataAdapter(query, connectionString);
                OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
                DataTable dt = new DataTable();

                da.Fill(dt);

                BindingSource bs = new BindingSource();
                bs.DataSource = dt;

                dgvCustomers.DataSource = bs;

                da.Update(dt);

                databaseHandler d = new databaseHandler();
                d.closeDatabaseConnection();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }
开发者ID:jetpacktuxedo,项目名称:library,代码行数:31,代码来源:frmViewCustomers.cs

示例6: Main

        static void Main(string[] args)
        {
            //dateTime.DataSet1TableAdapters.table1TableAdapter table = new dateTime.DataSet1TableAdapters.table1TableAdapter();
            //table.Insert("arif", "khan", "hasan", "1988-01-10", "100.00");
            //Console.ReadLine();

            OleDbConnection con = new OleDbConnection(@"Provider=VFPOLEDB.1;Data Source=D:\Documents and Settings\axkhan2\Desktop\table\table1.dbf");
            con.Open();
            OleDbDataAdapter adapt = new OleDbDataAdapter(@"select * from 'D:\Documents and Settings\axkhan2\Desktop\table\table1.dbf'", con);
            OleDbCommandBuilder build = new OleDbCommandBuilder(adapt);
            DataSet set = new DataSet();
            adapt.Fill(set);
            DataTable table = set.Tables[0];
            DataRow row = table.NewRow();
            row["firstname"] = "arifkhan";
            row["lastname"] = "khan";
            row["middlename"] = "mname";
            row["dob"] = DateTime.Now;
            row["amount"] = 100;
            table.Rows.Add(row);
           
            //adapt.Update(table);
            //adapt.UpdateCommand =  build.GetUpdateCommand();
            adapt.Update(table);
            //cmd.ExecuteNonQuery();
        }
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:26,代码来源:Program.cs

示例7: Button1_Click1

    protected void Button1_Click1(object sender, EventArgs e)
    {
        string username=this.TextBox1.Text;
        string con="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+System.Web.HttpContext.Current.Server.MapPath("App_data/db1.mdb");
        OleDbConnection ole=new OleDbConnection(con);
        DataSet ds=new DataSet();
        DataRow drow;
        ole.Open();
        OleDbCommand olec=new OleDbCommand("select * from yonghu where yname='"+username+"'",ole);
        int count=Convert.ToInt32(olec.ExecuteScalar());
        OleDbDataAdapter oda=new OleDbDataAdapter ("select * from yonghu",ole);
        OleDbCommandBuilder ob=new OleDbCommandBuilder(oda);
        oda.Fill(ds,"tab");
        if (count > 0)
        {
            this.Label1.Text = "昵称已存在,请重新输入!";
        }
        else
        {
            drow = ds.Tables["tab"].NewRow();
            drow[0] = ds.Tables["tab"].Rows.Count + 1;
            drow[1] = this.TextBox1.Text;
            ds.Tables["tab"].Rows.Add(drow);
            oda.Update(ds, "tab");
            ole.Close();

            Session["name"] = Request["TextBox1"];
            Application["message"] = "";
            Response.Redirect("HTMLPage.htm");
        }
    }
开发者ID:VivianWalker,项目名称:vivianwalker.github.com,代码行数:31,代码来源:liaotianshi.aspx.cs

示例8: DataTableInsert

        /// <summary>
        /// 插入数据通过Datatable
        /// </summary>
        /// <param name="_dt"></param>
        /// <returns>影响记录条数</returns>
        public override int DataTableInsert(DataTable _dt)
        {
            bool flag = false;
                int _nResult = 0;
                if (_dt == null)
                    return _nResult;
                string _sCmdText = string.Format("select * from {0} where 1=2", _dt.TableName);
                OleDbCommand _Command = (OleDbCommand)CreateCommand(_sCmdText, CommandType.Text);
                OleDbDataAdapter _adapter = new OleDbDataAdapter(_Command);
                OleDbDataAdapter _adapter1 = new OleDbDataAdapter(_Command);
                OleDbCommandBuilder _builder = new OleDbCommandBuilder(_adapter1);

                _adapter.InsertCommand = _builder.GetInsertCommand();

                if (_adapter.InsertCommand.Parameters.Count < _dt.Columns.Count)
                {
                    flag = true;//因为表中有自增字段,所以CommandBuild生成的InserttCommand的参数中少了自增字段
                    foreach (DataColumn _dc in _dt.Columns)
                    {
                        if (!_adapter.InsertCommand.Parameters.Contains(_dc.ColumnName))
                        {
                            _adapter.InsertCommand.CommandText =
                                _adapter.InsertCommand.CommandText.Insert(_adapter.InsertCommand.CommandText.IndexOf(") VALUES"), ',' + _dc.ColumnName);

                            _adapter.InsertCommand.CommandText =
                                _adapter.InsertCommand.CommandText.Insert(_adapter.InsertCommand.CommandText.Length - 1, ",?");

                            _adapter.InsertCommand.Parameters.Add("@" + _dc.ColumnName, OleDbType.Decimal, _dc.MaxLength, _dc.ColumnName);

                            if (_adapter.InsertCommand.Parameters.Count >= _dt.Columns.Count)
                                break;
                        }
                    }
                }

                if (flag)
                    this.ExecuteNoQuery(string.Format("SET IDENTITY_INSERT {0} on", _dt.TableName));

                this.BeginTransaction();
                try
                {
                    _adapter.InsertCommand.Transaction = _Command.Transaction;
                    _Command.CommandText = "delete from " + _dt.TableName;
                    _Command.ExecuteNonQuery();
                    _nResult = _adapter.Update(_dt);
                    this.CommitTransaction();
                }
                catch (Exception ex)
                {
                    this.RollbackTransaction();
                    throw ex;
                }
                finally
                {
                    if (flag)
                        this.ExecuteNoQuery(string.Format("SET IDENTITY_INSERT {0} OFF", _dt.TableName));
                }
                return _nResult;
        }
开发者ID:bluedusk,项目名称:DBHelper,代码行数:64,代码来源:OleDbHelper.cs

示例9: Gravar

		public void Gravar(DataSet ds, string tabela)
		{
			OleDbCommandBuilder cmdBuilder;
			OleDbDataAdapter adaptador;

			adaptador = new OleDbDataAdapter("select * from " + tabela, conexão);
			cmdBuilder = new OleDbCommandBuilder(adaptador);

			adaptador.Update(ds, tabela);
		}
开发者ID:andrepontesmelo,项目名称:imjoias,代码行数:10,代码来源:Dbf.cs

示例10: CapNhatBang

 public static void CapNhatBang(DataSet ds)
 {
     OleDbConnection cn = DataProvider.ConnectionData();
     string strSQL = "Select * From LoaiSach";
     OleDbDataAdapter da = new OleDbDataAdapter(strSQL, cn);
     OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
     da.Update(ds.Tables[0]);
     //B5: Dong ket noi CSDL
     cn.Close();
 }
开发者ID:hieu292,项目名称:quanlythuvien5n,代码行数:10,代码来源:LoaiSachDao.cs

示例11: Main

        public static void Main(string[] args)
        {
            WriteToEventLog("Calling AEPM Service...");

            var dt = new DataTable();
            var dset = new DataSet();
            Guid = args[0];

            //retrieve any records needing updating
            try
            {

                 using(var conn = new OleDbConnection(ConfigurationManager.AppSettings["AS400ConnectionStringDev"]))

                {
                    string sql = GetUnprocessMasterRecsString();
                    var objDataAdapter = new OleDbDataAdapter();
                    var cmd = new OleDbCommand(sql, conn);

                    objDataAdapter.SelectCommand = cmd;
                    objDataAdapter.SelectCommand.CommandTimeout = 0;

                    dt.Clear();
                    dset.Clear();

                    objDataAdapter.Fill(dt);
                    objDataAdapter.Fill(dset, "currentSelections");

                    var cb = new OleDbCommandBuilder(objDataAdapter);
                    AddParameters(cb);

                    //update records to 'S' for submitted
                    for (int i = 0; i < dset.Tables["currentSelections"].Rows.Count; i++)
                    {
                        dset.Tables["currentSelections"].Rows[i]["G_RETRN"] = 'S';
                    }

                    objDataAdapter.Update(dset, "currentSelections");

                    //submit records asynch
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        TestAsync(dt, i);
                    }

                }
            }
            catch (Exception ex)
            {
                WriteToEventLog(ex);
            }
        }
开发者ID:jlegacy,项目名称:AEPM_GetMaster,代码行数:52,代码来源:Program.cs

示例12: Main

	public static void Main(string [] str)
	{
		string path = "D:\\temp\\csc\\dataset";
		string table = path+"\\temp.dbf";
		
		OleDbConnection con = new OleDbConnection("Provider=VFPOLEDB.1;Data Source=D:\\temp\\csc\\dataset");
    	con.Open();
  
  try
  {
  	OleDbDataAdapter da = new OleDbDataAdapter("select * from "+table, con);
 // 	da.SelectCommand = new OleDbCommand("select * from "+table, con);
  da.UpdateCommand = new OleDbCommand("update "+ table+"set fname = ? where id = 1", con);
  
  da.UpdateCommand.Parameters.Add("fname", OleDbType.VarChar, 200, "@fname");
  da.UpdateCommand.Parameters.Add("fname", OleDbType.VarChar, 200, "@fname").SourceVersion = DataRowVersion.Original;

  DataTable tb = new DataTable();
  da.Fill(tb);
  /*	DataSet ds = new DataSet();
  	da.Fill(ds);
  	DataTable tb = ds.Tables[0];
  	DataRow rw = tb.NewRow();
  	rw["id"] = 4;
  	rw["fname"] = "afreen";
  	rw["lname"] = "khan";
  	rw["mname"] = "arif";
  */
 // tb.Rows.Add(rw);
 Console.WriteLine("Enter you first name");
  	DataRow rw = tb.Rows[0];
  	rw["fname"] = Console.ReadLine();
  //	Console.WriteLine("row added to table");
  //	OleDbCommandBuilder build = new OleDbCommandBuilder(da);
  	da.Update(tb);
  	Console.WriteLine("Table updated");  
   
    }
    catch(OleDbException ex)
    {
    	Console.WriteLine(ex.Message);
    }
    finally
    {
    	con.Close();
    }
	}
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:47,代码来源:example2.cs

示例13: Button1_Click

 protected void Button1_Click(object sender, EventArgs e)
 {
     string strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Web.HttpContext.Current.Server.MapPath("app_data/db1.mdb");
     OleDbConnection ole = new OleDbConnection(strconn);
     DataSet ds = new DataSet();
     DataRow drow;
     ole.Open();
     OleDbDataAdapter oda = new OleDbDataAdapter("select * from yh", strconn);
     OleDbCommandBuilder ob = new OleDbCommandBuilder(oda);
     oda.Fill(ds, "tab");
     drow = ds.Tables["tab"].NewRow();
     drow[0] = Session["yname"];
     drow[1] = this.TextBox1.Text;
     ds.Tables["tab"].Rows.Add(drow);
     oda.Update(ds, "tab");
     DataList1.DataSource = ds.Tables["tab"];
     DataList1.DataBind();
     ole.Close();
 }
开发者ID:VivianWalker,项目名称:vivianwalker.github.com,代码行数:19,代码来源:liuyan.aspx.cs

示例14: deleteToolStripMenuItem_Click

        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string row = dgvMovies[0, dgvMovies.CurrentRow.Index].Value.ToString();

            if (MessageBox.Show("Are you sure?", "Confirm Deletion", MessageBoxButtons.YesNo) == DialogResult.No) {
                MessageBox.Show("Request ignored");
                dgvMovies.ClearSelection();
                return;
            }

            try {
                connectionString = ConfigurationManager.AppSettings["DBConnectionString"] + frmHomeScreen.mUserFile;
                string query = "delete from Movie where UPC = '" + row + "';";
                string query2 = "delete from Actor where UPC = '" + row + "';";

                OleDbDataAdapter da = new OleDbDataAdapter(query, connectionString);
                OleDbDataAdapter da2 = new OleDbDataAdapter(query2, connectionString);
                OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
                OleDbCommandBuilder cb2 = new OleDbCommandBuilder(da2);
                DataTable dt = new DataTable();

                da.Fill(dt);

                BindingSource bs = new BindingSource();
                bs.DataSource = dt;

                dgvMovies.DataSource = bs;

                da.Update(dt);

            }
            catch (Exception ex) {
                MessageBox.Show("Unexpected error: " + ex);
            }
            finally {
                databaseHandler d = new databaseHandler();
                d.closeDatabaseConnection();
            }

            refresh();
            dgvMovies.ClearSelection();
        }
开发者ID:jetpacktuxedo,项目名称:library,代码行数:42,代码来源:frmViewMovies.cs

示例15: Write

        public void Write(CubeMetadata metadata)
        {
            if (metadata == null)
                throw new ArgumentNullException();

            GetSheets();
            if (_sheets.IndexOf(SheetName + "$") == -1)
                CreateNewSheet(SheetName);

            RaiseProgressStatus("Opening Xls file");

            DataTable dataTable = MetadataFileFormat.WriteInDataTable(metadata);
            dataTable.TableName = SheetName + "$";
            _rowTotal = dataTable.Rows.Count;

            using (var conn = new OleDbConnection(GetConnectionString(Filename)))
            {
                using (var da = new OleDbDataAdapter())
                {
                    var sb = new StringBuilder();
                    sb.AppendFormat("INSERT INTO [{0}$] (", SheetName);

                    foreach (DataColumn col in dataTable.Columns)
                        sb.AppendFormat(" {0},", col.ColumnName);
                    sb.Remove(sb.Length - 1, 1); //Remove the last comma
                    sb.Append(") VALUES (");
                    for (int i = 0; i < dataTable.Columns.Count; i++)
                        sb.Append(" ?,");
                    sb.Remove(sb.Length - 1, 1); //Remove the last comma
                    sb.Append(")");
                    da.InsertCommand = new OleDbCommand(sb.ToString(), conn);
                    foreach (DataColumn col in dataTable.Columns)
                        da.InsertCommand.Parameters.Add(string.Format("@{0}", col.ColumnName), OleDbType.VarChar, 255, col.ColumnName);

                    da.RowUpdated += new OleDbRowUpdatedEventHandler(OnRowUpdated);
                    conn.Open();
                    da.Update(dataTable);
                    da.RowUpdated -= new OleDbRowUpdatedEventHandler(OnRowUpdated);
                }
            }
            RaiseProgressStatus("Xls file written");
        }
开发者ID:zyh329,项目名称:nbi,代码行数:42,代码来源:MetadataExcelOleDbWriter.cs


注:本文中的System.Data.OleDb.OleDbDataAdapter.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。