接上贴.把代码粘贴就会看到界面了(另外加个主函数就可以了),我已经做出来了插入功能,但修改和删除功能仍然解决不了.数据库随便做一个就行了,用SQL.
请大家帮我把程序修改后,然后把整个程序的代码贴上来.谢谢了,我会立即结分.
我的代码:
                                   this.txtBookAccessCode.Location  =  new  System.Drawing.Point(124,  128);  
                                   this.txtBookAccessCode.Name  =  "txtBookAccessCode";  
                                   this.txtBookAccessCode.Size  =  new  System.Drawing.Size(152,  21);  
                                   this.txtBookAccessCode.TabIndex  =  20;  
                                   this.txtBookAccessCode.Text  =  "";  
                                   this.txtBookAccessCode.Leave  +=  new  System.EventHandler(this.txtBookAccessCode_Leave);  
                                                                      this.txtStdID.Location  =  new  System.Drawing.Point(124,  88);  
                                   this.txtStdID.Name  =  "txtStdID";  
                                   this.txtStdID.Size  =  new  System.Drawing.Size(152,  21);  
                                   this.txtStdID.TabIndex  =  19;  
                                   this.txtStdID.Text  =  "";  
                                                                      this.txtStdName.Location  =  new  System.Drawing.Point(124,  48);  
                                   this.txtStdName.Name  =  "txtStdName";  
                                   this.txtStdName.Size  =  new  System.Drawing.Size(152,  21);  
                                   this.txtStdName.TabIndex  =  18;  
                                   this.txtStdName.Text  =  "";  
                                                                     this.lblIssueDate.Location  =  new  System.Drawing.Point(28,  256);  
                                   this.lblIssueDate.Name  =  "lblIssueDate";  
                                   this.lblIssueDate.Size  =  new  System.Drawing.Size(88,  24);  
                                   this.lblIssueDate.TabIndex  =  17;  
                                   this.lblIssueDate.Text  =  "借阅日期:";  
                                   
                                   this.lblAuthor.Location  =  new  System.Drawing.Point(28,  216);  
                                   this.lblAuthor.Name  =  "lblAuthor";  
                                   this.lblAuthor.Size  =  new  System.Drawing.Size(88,  24);  
                                   this.lblAuthor.TabIndex  =  16;  
                                   this.lblAuthor.Text  =  "作者:";  
                                   
                                   this.lblBookName.Location  =  new  System.Drawing.Point(28,  176);  
                                   this.lblBookName.Name  =  "lblBookName";  
                                   this.lblBookName.Size  =  new  System.Drawing.Size(88,  24);  
                                   this.lblBookName.TabIndex  =  15;  
                                   this.lblBookName.Text  =  "书名:";  
                                  
                                   this.lblBookAccessCode.Location  =  new  System.Drawing.Point(28,  136);  
                                   this.lblBookAccessCode.Name  =  "lblBookAccessCode";  
                                   this.lblBookAccessCode.Size  =  new  System.Drawing.Size(88,  24);  
                                   this.lblBookAccessCode.TabIndex  =  14;  
                                   this.lblBookAccessCode.Text  =  "图书访问号:";  
                                    
                                   this.lblStdID.Location  =  new  System.Drawing.Point(28,  88);  
                                   this.lblStdID.Name  =  "lblStdID";  
                                   this.lblStdID.Size  =  new  System.Drawing.Size(88,  24);  
                                   this.lblStdID.TabIndex  =  13;  
                                   this.lblStdID.Text  =  "学号:";  
                                    
                                   this.lblStdName.Location  =  new  System.Drawing.Point(28,  48);  
                                   this.lblStdName.Name  =  "lblStdName";  
                                   this.lblStdName.Size  =  new  System.Drawing.Size(88,  24);  
                                   this.lblStdName.TabIndex  =  12;  
                                   this.lblStdName.Text  =  "学生姓名:";  
                                   
                                   this.grp2.Controls.Add(this.dbgBooksDt);  
                                   this.grp2.Location  =  new  System.Drawing.Point(336,  16);  
                                   this.grp2.Name  =  "grp2";  
                                   this.grp2.Size  =  new  System.Drawing.Size(496,  312);  
                                   this.grp2.TabIndex  =  16;  
                                   this.grp2.TabStop  =  false;  
                                   this.grp2.Text  =  "借阅详细信息";  
                                   
                                   this.dbgBooksDt.DataMember  =  "";  
                                   this.dbgBooksDt.HeaderForeColor  =  System.Drawing.SystemColors.ControlText;  
                                   this.dbgBooksDt.Location  =  new  System.Drawing.Point(16,  40);  
                                   this.dbgBooksDt.Name  =  "dbgBooksDt";  
                                   this.dbgBooksDt.Size  =  new  System.Drawing.Size(464,  232);  
                                   this.dbgBooksDt.TabIndex  =  13;  
                                    
                                   this.btnMod.Location  =  new  System.Drawing.Point(528,  360);  
                                   this.btnMod.Name  =  "btnMod";  
                                   this.btnMod.Size  =  new  System.Drawing.Size(88,  24);  
                                   this.btnMod.TabIndex  =  17;  
                                   this.btnMod.Text  =  "修改(&M)";  
                                   this.btnMod.Click  +=  new  System.EventHandler(this.btnMod_Click);  
                                   
                                   this.btnDel.Location  =  new  System.Drawing.Point(632,  360);  
                                   this.btnDel.Name  =  "btnDel";  
                                   this.btnDel.Size  =  new  System.Drawing.Size(88,  24);  
                                   this.btnDel.TabIndex  =  18;  
                                   this.btnDel.Text  =  "删除(&D)";  
                                                                      this.AutoScaleBaseSize  =  new  System.Drawing.Size(6,  14);  
                                   this.ClientSize  =  new  System.Drawing.Size(848,  398);  
                                   this.Controls.Add(this.btnDel);  
                                   this.Controls.Add(this.btnMod);  
                                   this.Controls.Add(this.grp2);  
                                   this.Controls.Add(this.grp1);  
                                   this.Controls.Add(this.btnExit);  
                                   this.Controls.Add(this.btnIssueBook);  
                                   this.Name  =  "Form3";  
                                   this.Text  =  "借阅图书";  
                                   this.Load  +=  new  System.EventHandler(this.Form3_Load);  
                                   this.grp1.ResumeLayout(false);  
                                   this.grp2.ResumeLayout(false);  
                                   ((System.ComponentModel.ISupportInitialize)(this.dbgBooksDt)).EndInit();  
                                   this.ResumeLayout(false);  
 
                       }  
                       #endregion

解决方案 »

  1.   

    http://singlepine.cnblogs.com/archive/2005/11/01/266538.aspxlZ,看下小山的blog
    功能强大的DataGrid
      

  2.   

    如果你是要迭代所有记录的话:
                     bool blNotFound = true;
    foreach(DataRow dr in objDataSet.Tables[0].Rows)
    {
    if(dr["StudentID"].Equals(this.txtStdID.Text))
    {
    DataRow objDataRow=dr;
    objDataRow.Delete(); objSqlDataAdapter.Update(objDataSet,"Issue_Details");
    objDataSet.AcceptChanges();
    this.dbgBooksDt.Update();
    MessageBox.Show("已经删除完成");
                                             blNotFound = false;
    break;
    }
    }
                        if (blNotFound)
                        {
     MessageBox.Show("没有找到记录");                     }