SqlCommand sqlCmd=new SqlCommand();
            sqlCmd.CommandText="P_GetDutyTaskInfo";
            sqlCmd.CommandType=CommandType.StoredProcedure ;            dsDutyTask=dataAccess.FillDataSetMasterDetail(dsDutyTask,sqlCmd,"HOD2DUTY","HOD2DUTY_D");            //MessageBox.Show(this.dsDutyTask.Tables[0].Rows[0][0].ToString());
            //MessageBox.Show(this.dsDutyTask.Tables[1].Rows[2][0].ToString());
            DataRelation duty_rel = dsDutyTask.Relations.Add("les",
                this.dsDutyTask.Tables[0].Columns["ID_HOD2DUTY"],
                this.dsDutyTask.Tables[1].Columns["ID_DUTY"]);
            this.dataGridView1.DataSource = this.dsDutyTask.Tables[0];
            this.dataGridView2.DataSource = this.dsDutyTask.Tables[1];
========================================================================
我设定好dataRelation后运行也没问题,
但是当我点DataGridView1中的一行时,Datagridview2中的数据并不会发生改变,为什么?

解决方案 »

  1.   

    未处理 System.Exception
      Message="更新数据失败!"
      Source="EIP"
      StackTrace:
           在 EIP.Class.DataAccess.UpdateMasterDeatil(SqlDataAdapter adapterMaster, SqlDataAdapter adapterDetail, DataSet ds) 位置 C:\Documents and Settings\kyle\桌面\EIP\EIP\Class\DataAccess.cs:行号 104
           在 EIP.Frm.frmDutyTask.toolSave_Click(Object sender, EventArgs e) 位置 C:\Documents and Settings\kyle\桌面\EIP\EIP\Frm\frmDutyTask.cs:行号 118
           在 System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
           在 System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
           在 System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
           在 System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
           在 System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
           在 System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
           在 System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
           在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           在 System.Windows.Forms.Control.WndProc(Message& m)
           在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
           在 System.Windows.Forms.ToolStrip.WndProc(Message& m)
           在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           在 System.Windows.Forms.Application.Run(Form mainForm)
           在 EIP.Program.Main() 位置 C:\Documents and Settings\kyle\桌面\EIP\EIP\Program.cs:行号 19
           在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
           在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           在 System.Threading.ThreadHelper.ThreadStart()