续(这个例子是针对ACCESS的更新、删除、还有定位的,希望能对你有所帮助)
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
// btn_help
            //
            this.btn_help.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
            this.btn_help.Location = new System.Drawing.Point(360, 280);
            this.btn_help.Name = "btn_help";
            this.btn_help.Size = new System.Drawing.Size(88, 24);
            this.btn_help.TabIndex = 3;
            this.btn_help.Text = "帮 助(&h)";
            this.btn_help.Click += new System.EventHandler(this.btn_help_Click);
            //
            // label5
            //
            this.label5.BackColor = System.Drawing.Color.Olive;
            this.label5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.label5.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
            this.label5.Location = new System.Drawing.Point(48, 192);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(152, 24);
            this.label5.TabIndex = 1;
            this.label5.Text = "市场价格:";
            this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            //
            // txt_bookstock
            //
            this.txt_bookstock.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.txt_bookstock.Location = new System.Drawing.Point(232, 240);
            this.txt_bookstock.Name = "txt_bookstock";
            this.txt_bookstock.Size = new System.Drawing.Size(216, 21);
            this.txt_bookstock.TabIndex = 2;
            this.txt_bookstock.Text = "";
            //
            // dataedit
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.AutoScroll = true;
            this.BackColor = System.Drawing.Color.Olive;
            this.ClientSize = new System.Drawing.Size(536, 389);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.statusBar,
                                                                          this.btn_help,
                                                                          this.txt_BookId,
                                                                          this.label2,
                                                                          this.label1,
                                                                          this.label3,
                                                                          this.label4,
                                                                          this.label5,
                                                                          this.label6,
                                                                          this.txt_BookName,
                                                                          this.txt_AuthorName,
                                                                          this.txt_bookprice,
                                                                          this.txt_bookstock,
                                                                          this.btn_Delete,
                                                                          this.btn_update,
                                                                          this.btn_movenext,
                                                                          this.btn_movefirst,
                                                                          this.btn_moveprevious,
                                                                          this.btn_movelast});
            this.Name = "dataedit";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "dataedit";
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.ResumeLayout(false);

        }
        #endregion

        private void MovePrevious()
        {
            if (myBind.Position == 0)
            {
                statusBar.Text = "数据已经到头";
            }
            else
            {
                myBind.Position -= 1;
                statusBar.Text = "当前位置:" +myBind.Position.ToString();
            }
        }

        private void MoveFirst()
        {
            myBind.Position = 0;
            statusBar.Text = "当前位置:" +myBind.Position.ToString();
        }

        private void MoveNext()
        {
            if (myBind.Position == myBind.Count-1)
            {
                statusBar.Text = "数据已经到尾";
            }
            else
            {
                myBind.Position += 1;
                statusBar.Text = "当前位置:" +myBind.Position.ToString();
            }
        }

        private void MoveLast()
        {
            myBind.Position = myBind.Count-1;
            statusBar.Text = "当前位置:" +myBind.Position.ToString();
        }

        private void btn_movefirst_Click(object sender, System.EventArgs e)
        {
            MoveFirst();
        }

        private void btn_moveprevious_Click(object sender, System.EventArgs e)
        {
            MovePrevious();
        }

        private void btn_movenext_Click(object sender, System.EventArgs e)
        {
            MoveNext();
        }

        private void btn_movelast_Click(object sender, System.EventArgs e)
        {
            MoveLast();
        }

        private void btn_help_Click(object sender, System.EventArgs e)
        {
            MessageBox.Show("数据库操作练习——定位、更新删除",System.DateTime.Now.ToShortDateString());
        }

        private void btn_Delete_Click(object sender, System.EventArgs e)
        {
            try
            {
                string strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=book.mdb";
                OleDbConnection conn = new OleDbConnection(strconn);
                
                conn.Open();
                string strdelete = "select * from bookstock";
                OleDbDataAdapter adapter = new OleDbDataAdapter(strdelete,conn);

                myDataSet.Tables["bookstock"].Rows[myBind.Position].Delete();
                adapter.Update(myDataSet,"bookstock");

                statusBar.Text = "记录已经删除";
                conn.Close();
            }
            catch(Exception ed)
            {
                statusBar.Text = "发生错误,原因:" + ed.Message; 共2页: 上一页 1 [2] 下一页 <script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
阅读更多
个人分类: .net
想对作者说点什么? 我来说一句

2401资料,希望能对你有所帮助

2009年09月22日 397B 下载

HTML DOM 文档

2007年11月15日 175KB 下载

清华大学数据结构课件 PPT

2009年03月03日 1.13MB 下载

ACCESS条码打印案例

2012年10月24日 280KB 下载

没有更多推荐了,返回首页

不良信息举报

续(这个例子是针对ACCESS的更新、删除、还有定位的,希望能对你有所帮助)

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭