• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# OleDb.OleDbCommandBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



OleDbCommandBuilder类属于System.Data.OleDb命名空间,在下文中一共展示了OleDbCommandBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: updated_dataview

        private void updated_dataview()
        {
            OleDbConnection connection = new OleDbConnection();
            connection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + reference.Getdb();
            OleDbDataAdapter dataAdapter;
            try
            {
                dataAdapter = new OleDbDataAdapter("select * from printer", connection);

                OleDbCommandBuilder command = new OleDbCommandBuilder(dataAdapter);

                // Populate a new data table and bind it to the BindingSource.
                printers = new DataTable();
                printers.Locale = System.Globalization.CultureInfo.InvariantCulture;
                dataAdapter.Fill(printers);

                printers_listbox.DataSource = printers;
                printers_listbox.DisplayMember = "location";
                currentchart = printers.Rows[0].ItemArray.GetValue(0).ToString();
            }
            catch (Exception e3)
            {
                MessageBox.Show(e3.Message);
            }
            finally
            {
                connection.Close();
            }
        }
开发者ID:paulkloos,项目名称:pagecount,代码行数:29,代码来源:Form3.cs


示例2: 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


示例3: 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


示例4: ReserveMenu_Load

        private void ReserveMenu_Load(object sender, EventArgs e)
        {
            AirAsianDataBase = new OleDbConnection(connectionString);

            AirAsianDataBase.Open();

            string strSelect = "Select * from AirCraft";

            TripGridView.DataSource = null;
            TripGridView.Rows.Clear();
            TripGridView.Refresh();

            OleDbDataAdapter da = new OleDbDataAdapter( strSelect, AirAsianDataBase);
            OleDbCommandBuilder cBuilder = new OleDbCommandBuilder(da);
            DataTable dataTable = new DataTable();
            da.Fill(dataTable);

            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                TripGridView.Rows.Add(
                    dataTable.Rows[i][0],
                    dataTable.Rows[i][1],
                    dataTable.Rows[i][2],
                    dataTable.Rows[i][3],
                    dataTable.Rows[i][4],
                    dataTable.Rows[i][5]);
            }

            AirAsianDataBase.Close();
        }
开发者ID:Raydivine,项目名称:Plane-Ticket-Reservation-System,代码行数:30,代码来源:ReserveMenu.cs


示例5: GetRecords

        public override DataTable GetRecords(string strWhere, string strGroupBy, string strOrderBy)
        {
            if (m_pOleDbConnection != null)
            {
                try
                {
                    m_nCurrentRowIndex = 0;

                    string commandText = "Select * from "
                        + "(Select LineNodeID as LineID,X1 as PX1,Y1 as PY1,X2 as PX2,Y2 as PY2,-1 from LineNodeEx Where EntityID=-1 "
                        + "union Select LineNodeID as LineID,X2 as PX1,Y2 as PY1,X1 as PX2,Y1 as PY2,1 from LineNodeEx Where EntityID=-1) "
                        + "Order By PX1,PY1,PX2,PY2,LineID";

                    m_pOleDbDataAdapter = new OleDbDataAdapter(commandText, m_pOleDbConnection);

                    OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(m_pOleDbDataAdapter);

                    return GetNextRecords();
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(ex);
                }
            }
            return null;
        }
开发者ID:hy1314200,项目名称:HyDM,代码行数:26,代码来源:LineNodeExView.cs


示例6: subGetData

        private void subGetData(string _strSELECT)
        {
            try
            {
                // Specify a connection string. Replace the given value with a
                // valid connection string for a Northwind SQL Server sample
                // database accessible to your system.
                String strConn = clsAppSettings.GetAppSettings().strCTConn;

                // Create a new data adapter based on the specified query.
                daMORNCOAAlerts = new OleDbDataAdapter(_strSELECT, strConn);

                // Create a command builder to generate SQL update, insert, and
                // delete commands based on _strSELECT. These are used to
                // update the database.
                OleDbCommandBuilder cmdMORNCOAAlerts = new OleDbCommandBuilder(daMORNCOAAlerts);

                // Populate a new data table and bind it to the BindingSource.
                DataTable dtMORNCOAAlerts = new DataTable();
                dtMORNCOAAlerts.Locale = System.Globalization.CultureInfo.InvariantCulture;
                daMORNCOAAlerts.Fill(dtMORNCOAAlerts);
                srcMORNCOAAlerts.DataSource = dtMORNCOAAlerts;
            }
            catch (OleDbException)
            {
                MessageBox.Show("To run this example, replace the value of the " +
                    "strConn variable with a connection string that is " +
                    "valid for your system.");
            }
        }
开发者ID:khallgren,项目名称:CTWebMgmt,代码行数:30,代码来源:frmMORNCOAAlerts.cs


示例7: Test_Command_CommandBuilder

        private static void Test_Command_CommandBuilder()
        {
            (new OleDbCommand("drop table if exists t", conn)).ExecuteNonQuery();
            (new OleDbCommand("create table t(id int not null default 1,name string default 'cubrid',PRIMARY KEY (id))", conn)).ExecuteNonQuery();
            (new OleDbCommand("insert into t(id,name) value(1,'cubrid');", conn)).ExecuteNonQuery();

            DataSet dataSet = new DataSet();
            DataTable dataTable = new DataTable();
            string query = "select id,name from t";
            OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, conn);

            OleDbCommandBuilder commandBuilder =new OleDbCommandBuilder(dataAdapter);

            dataAdapter.Fill(dataTable);

            //Without the OleDbCommandBuilder this line would fail.
            foreach (System.Data.DataRow row in dataTable.Rows)
            {
                foreach (System.Data.DataColumn col in dataTable.Columns)
                {
                    Assert.AreEqual(row[col], 1);
                    break;
                }
            }

            OleDbCommand t1 = commandBuilder.GetInsertCommand();
            Assert.AreEqual(t1.CommandText, "INSERT INTO T DEFAULT VALUES");
        }
开发者ID:CUBRID,项目名称:cubrid-oledb,代码行数:28,代码来源:TestOleDbCommandBuilder.cs


示例8: FrmConfigDatabase_Load

     private void FrmConfigDatabase_Load(object sender, EventArgs e)
     {
         if (m_cnADONetConnection.State == ConnectionState.Open)
         {
             m_cnADONetConnection.Close();
         }
         m_cnADONetConnection.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Windows.Forms.Application.StartupPath + @"\ConfigDatabase.mdb";
         
         m_cnADONetConnection.Open();
         m_daDataAdapter = new OleDbDataAdapter("Select * From DatabaseInfo", m_cnADONetConnection);
         OleDbCommandBuilder m_cbCommandBuilder = new OleDbCommandBuilder(m_daDataAdapter);
         m_daDataAdapter.Fill(m_dtDict);
         if(m_dtDict.Rows.Count != 0)
         {
             listBox1.Items.Add("Tên Server : " + m_dtDict.Rows[0]["ServerName"]);
             listBox1.Items.Add("Tên Instance : " + m_dtDict.Rows[0]["InstanceName"]);
             listBox1.Items.Add("Tên Database : " + m_dtDict.Rows[0]["DatabaseName"]);
             if (m_dtDict.Rows[0]["Mode"].ToString() == "AUT")
             {
                 listBox1.Items.Add("Window Authentication");
             }
             else
             {
                 listBox1.Items.Add("UserName : " + m_dtDict.Rows[0]["UserID"]);
                 userId = m_dtDict.Rows[0]["UserID"].ToString();
                 pass = m_dtDict.Rows[0]["Password"].ToString();
             }
             mode = m_dtDict.Rows[0]["Mode"].ToString();
             serverName = m_dtDict.Rows[0]["ServerName"].ToString();
             instanceName = m_dtDict.Rows[0]["InstanceName"].ToString();
             databaseName = m_dtDict.Rows[0]["DatabaseName"].ToString();
             isConfiged = true;
         }
 
     }
开发者ID:hpbaotho,项目名称:thanhtuan,代码行数:35,代码来源:FrmConfigDatabase.cs


示例9: button2_Click

        private void button2_Click(object sender, EventArgs e)
        {
            String query = "select * from Admin ;";
            DatabaseManager dbManager = DatabaseManager.dataBaseManager();
            dbManager.BookConn = new OleDbConnection(dbManager.getConnParam());
            OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, dbManager.BookConn);
            OleDbCommandBuilder cBuilder = new OleDbCommandBuilder(dAdapter);
            DataTable dataTable = new DataTable();
            DataSet ds = new DataSet();
            dAdapter.Fill(dataTable);

            DataRow[] dra = dataTable.Select("");
            foreach (DataRow dr in dra)
            {
                if (textBox1.Text.Equals(dr["Sifre"] + ""))
                {
                    AdminEkrani f22 = new AdminEkrani();
                    this.Visible = false;
                    f22.Show();
                }
                else
                {
                    MessageBox.Show("ADMIN SIFRESI HATALI");
                }
            }
        }
开发者ID:csmali,项目名称:Rez,代码行数:26,代码来源:SifreEkrani.cs


示例10: 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


示例11: 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


示例12: DataBindingFeatures_Load

        // ExStart:FillDataSet
        private void DataBindingFeatures_Load(object sender, EventArgs e)
        {
            // The path to the documents directory.
            string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Creating Select query to fetch data from database
            string query = "SELECT * FROM Products ORDER BY ProductID";

            // Creating connection string to connect with database
            string conStr = @"Provider=microsoft.jet.oledb.4.0;Data Source=" + dataDir + "dbDatabase.mdb";

            // Creating OleDbDataAdapter object that will be responsible to open/close connections with database, fetch data and fill DataSet with data
            adapter = new OleDbDataAdapter(query, conStr);

            // Setting MissingSchemaAction to AddWithKey for getting necesssary primary key information of the tables
            adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;

            /*
             * Creating OleDbCommandBuilder object to create insert/delete SQL commmands
             * automatically that are used by OleDbDatAdapter object for updating
             * changes to the database
            */
            cb = new OleDbCommandBuilder(adapter);

            // Creating DataSet object
            ds = new DataSet();

            // Filling DataSet with data fetched by OleDbDataAdapter object
            adapter.Fill(ds, "Products");
        }
开发者ID:aspose-cells,项目名称:Aspose.Cells-for-.NET,代码行数:31,代码来源:DataBindingFeature.cs


示例13: fillgv

        public void fillgv(string query)
        {
            OleDbConnection connection = new OleDbConnection();
            connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\sciencedb.accdb";
            OleDbCommand oledbRunCommand = new OleDbCommand();
            oledbRunCommand.CommandText = query;
            oledbRunCommand.CommandType = CommandType.Text;
            oledbRunCommand.Connection = connection;

            //create an OleDbDataAdapter to execute the query
            OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connection);

            //create a command builder
            OleDbCommandBuilder cBuilder = new OleDbCommandBuilder(dAdapter);

            //create a DataTable to hold the query results

            //fill the DataTable
            dAdapter.Fill(dTable);

            //the DataGridView
            //DataGridView dgView = new DataGridView();
            //BindingSource to sync DataTable and DataGridView
            BindingSource bSource = new BindingSource();

            //set the BindingSource DataSource
            bSource.DataSource = dTable;

            //set the DataGridView DataSource
            locationTableDataGridView.DataSource = bSource;
            connection.Close();
        }
开发者ID:bones05,项目名称:ScienceLab,代码行数:32,代码来源:EquipmentDetails.cs


示例14: btnSales_Click

        private void btnSales_Click(object sender, EventArgs e)
        {
            try
            {
                loginConn.Open();

                string strSelect = "SELECT * FROM TopSales";
                dataGridView1.DataSource = null;
                dataGridView1.Rows.Clear();
                dataGridView1.Refresh();

                OleDbDataAdapter da = new OleDbDataAdapter(strSelect, loginConn);
                OleDbCommandBuilder cBuilder = new OleDbCommandBuilder(da);
                DataTable dataTable = new DataTable();
                da.Fill(dataTable);

                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    dataGridView1.Rows.Add(dataTable.Rows[i][0], dataTable.Rows[i][1]);
                    dataGridView1.Sort(dataGridView1.Columns["TotalTransaction"], ListSortDirection.Descending);
                }

                loginConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                loginConn.Close();
            }
        }
开发者ID:JacksonTeh,项目名称:TicketReservationSystem,代码行数:30,代码来源:Login.cs


示例15: getData

        private void getData(string sqlCommand)
        {
            try
            {
                users = new DataSet();
                dataAdapter = new OleDbDataAdapter(sqlCommand, DbConn.connString);
                dataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;

                OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter);
                commandBuilder.QuotePrefix = "[";
                commandBuilder.QuoteSuffix = "]";

                dataAdapter.Fill(users,"users");

                dataGridView.DataSource = users.Tables["users"];
                dataGridView.AutoGenerateColumns = true;
            //                dataGridView.Columns[0].ReadOnly = true;

            }
            catch (Exception e)
            {

                MessageBox.Show(e.Message);
            }
        }
开发者ID:chunkin,项目名称:ClassManagementSystem,代码行数:25,代码来源:UMForm.cs


示例16: GetRecords

        public override DataTable GetRecords(string strWhere, string strGroupBy, string strOrderBy)
        {
            if (m_pOleDbConnection != null)
            {
                try
                {
                    m_nCurrentRowIndex = 0;
                    /*
                     * Select a.LineNodeID,b.LineNodeID,a.PolygonID,b.PolygonID,a.IsReverse,b.IsReverse,a.EntityID,a.IsFromLine From LineNodeEx as a left join LineNodeEx as b on a.OrtherIndexID=b.LineNodeID Order By a.PolygonID,a.LineIndex
                     * */

                    string commandText = "Select a.LineNodeID as LineNodeID,b.LineNodeID as OtherLineNodeID,a.PolygonID as PolygonID,b.PolygonID as OtherPolygonID,a.IsReverse as IsReverse,b.IsReverse as OtherIsReverse,a.EntityID as EntityID,b.EntityID as OtherEntityID,a.LineIndex as LineIndex,b.LineIndex as OtherLineIndex"//,a.IsFromLine as IsFromLine
                        + " From LineNodeEx as a left join LineNodeEx as b on a.OrtherLineNodeID=b.LineNodeID Where a.IsFromLine=-1"
                        + " Order By a.PolygonID,a.LineIndex";

                    m_pOleDbDataAdapter = new OleDbDataAdapter(commandText, m_pOleDbConnection);

                    OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(m_pOleDbDataAdapter);

                    return GetNextRecords();
                }
                catch (Exception ex)
                {
                    LogAPI.WriteErrorLog(ex);
                }
            }
            return null;
        }
开发者ID:hy1314200,项目名称:HyDM,代码行数:28,代码来源:MatchLineNodeView.cs


示例17: GetData

        private void GetData(string selectCommand)
        {
            try
            {
                // Specify a connection string. Replace the given value with a 
                // valid connection string for a Northwind SQL Server sample
                // database accessible to your system.
                //System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Otros\Documents\PVI_Alumnos2.accdb");
                String conn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Otros\\Documents\\PVI_Alumnos2.accdb";
                // Create a new data adapter based on the specified query.
                dataAdapter = new OleDbDataAdapter(selectCommand, conn);

                // Create a command builder to generate SQL update, insert, and
                // delete commands based on selectCommand. These are used to
                // update the database.
                OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter);

                // Populate a new data table and bind it to the BindingSource.
                table = new DataSet("Alumnos");
                //table.Locale = System.Globalization.CultureInfo.InvariantCulture;
                dataAdapter.Fill(table);
                dataGridView1.DataSource = table.Tables[0];
                //bindingSource1.DataSource = table;

                // Resize the DataGridView columns to fit the newly loaded content.
                dataGridView1.AutoResizeColumns(
                    DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
            }
            catch (SqlException)
            {
                MessageBox.Show("To run this example, replace the value of the " +
                    "connectionString variable with a connection string that is " +
                    "valid for your system.");
            }
        }
开发者ID:Leloucas,项目名称:CSharp-Alumnos,代码行数:35,代码来源:Form1.cs


示例18: GetData

        private void GetData(string selectCommand, BindingSource a, DataTable b)
        {
            try
            {
                // Specify a connection string. Replace the given value with a
                // valid connection string for a Northwind SQL Server sample
                // database accessible to your system.

                // Create a new data adapter based on the specified query.
                OleDbDataAdapter dataAdapter = new OleDbDataAdapter(selectCommand, connexionstring);

                // Create a command builder to generate SQL update, insert, and
                // delete commands based on selectCommand. These are used to
                // update the database.
                OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter);

                // Populate a new data table and bind it to the BindingSource.

                b.Locale = System.Globalization.CultureInfo.InvariantCulture;
                dataAdapter.Fill(b);
                a.DataSource = b;

                // Resize the DataGridView columns to fit the newly loaded content.
                /* Vente_JourdataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
                 Stock_dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
                 Historique_dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);*/
            }
            catch (OleDbException)
            {
                MessageBox.Show("Erreur !!! ");

            }
        }
开发者ID:diopisemou,项目名称:GitHub,代码行数:33,代码来源:avertstock.cs


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# OleDb.OleDbConnection类代码示例发布时间:2022-05-26
下一篇:
C# OleDb.OleDbCommand类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap