private void SaveChg_Click(object sender, System.EventArgs e)
{
try
{
int row=this.UpdStuGrdDg.CurrentCell.RowNumber;
this.UpdStuGrdDg.CurrentCell=new DataGridCell(row+1,0);
if(UpdClassStudset.HasChanges())//如果改动是在根据乡镇检索的结果集上进行的那么,更改该结果集
{
UpdSconn=new SqlConnection(UpdStuconnstr);
UpdStuGrdsqlda=new SqlDataAdapter(this.UpdStustrconnClass,this.UpdSconn);
SqlComm=new SqlCommandBuilder(UpdStuGrdsqlda);
// SqlComm = new SqlDataAdapter
// SqlDataAda = new SqlDataAdapter(UpdStuGrdsqlda);
this.UpdStuGrdsqlda.Update(this.UpdClassStudset.GetChanges(),"HuZhu");
MessageBox.Show("保存修改成功!","信息");
}
else if(UpdNameStudset.HasChanges())//如果改动是在根据户主姓名检索的结果集上进行的那么,更改该结果集
{
UpdSconn=new SqlConnection(UpdStuconnstr);
UpdStuGrdsqlda=new SqlDataAdapter(this.UpdStustrconnName,UpdSconn);
SqlComm=new SqlCommandBuilder(UpdStuGrdsqlda);
UpdStuGrdsqlda.Update(this.UpdNameStudset.GetChanges(),"HuZhu");
MessageBox.Show("保存修改成功!","信息");
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString(),"信息");
}
}
//删除户主记录
private void DelRecord_Click(object sender, System.EventArgs e)
{
int rowNumber=this.UpdStuGrdDg.CurrentCell.RowNumber;
try
{
this.UpdClassStudset.Tables[0].Rows[rowNumber].Delete();
this.UpdNameStudset.Tables[0].Rows[rowNumber].Delete();
UpdSconn=new SqlConnection(UpdStuconnstr);
UpdStuGrdsqlda=new SqlDataAdapter("",UpdSconn);
SqlComm=new SqlCommandBuilder(UpdStuGrdsqlda);
UpdStuGrdsqlda.Update(this.UpdNameStudset.GetChanges(),"HuZhu");
UpdStuGrdsqlda.Update(this.UpdClassStudset.GetChanges(), "HuZhu");
MessageBox.Show("删除成功!","信息");
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString(),"信息"); }
} private void UpdateStu_Load()
{ }
解决方案 »
- 救命!UDP通讯问题,Server发送数据,Client无法接收!!!
- 都说程序员逻辑思维强,高手帮解答下
- 一个很简单的问题,C#.NET中退出过程是什么语句。
- 怎么用正则表达式去匹配一个int数里有没有某一个数
- 点中DataGridView中的一行数据,在点击按钮,删除数据,数据库中也删除
- 菜鸟问,怎么做聊天室啊,感谢回答!!!!!
- C#开发TUXEDO客户端问题
- 关于这本书
- 高手们:关于viewstate如何保存做对象
- 人气不旺啊。发个编程技巧吧,大家都看看。
- 急急急.....VS2003 Crystal report XI. Load report failed.
- 谁用NETSerialComm做过异步调用的例子?100分
private void SaveChg_Click(object sender, System.EventArgs e)
{
try
{
int row=this.UpdStuGrdDg.CurrentCell.RowNumber;
this.UpdStuGrdDg.CurrentCell=new DataGridCell(row+1,0);
if(UpdClassStudset.HasChanges())//如果改动是在根据乡镇检索的结果集上进行的那么,更改该结果集
{
UpdSconn=new SqlConnection(UpdStuconnstr);
UpdStuGrdsqlda=new SqlDataAdapter(this.UpdStustrconnClass,this.UpdSconn);
SqlComm=new SqlCommandBuilder(UpdStuGrdsqlda);
// SqlComm = new SqlDataAdapter
// SqlDataAda = new SqlDataAdapter(UpdStuGrdsqlda);
this.UpdStuGrdsqlda.Update(this.UpdClassStudset.GetChanges(),"HuZhu");
MessageBox.Show("保存修改成功!","信息");
}
else if(UpdNameStudset.HasChanges())//如果改动是在根据户主姓名检索的结果集上进行的那么,更改该结果集
{
UpdSconn=new SqlConnection(UpdStuconnstr);
UpdStuGrdsqlda=new SqlDataAdapter(this.UpdStustrconnName,UpdSconn);
SqlComm=new SqlCommandBuilder(UpdStuGrdsqlda);
UpdStuGrdsqlda.Update(this.UpdNameStudset.GetChanges(),"HuZhu");
MessageBox.Show("保存修改成功!","信息");
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString(),"信息");
}
}
//删除户主记录
private void DelRecord_Click(object sender, System.EventArgs e)
{
int rowNumber=this.UpdStuGrdDg.CurrentCell.RowNumber;
try
{
this.UpdClassStudset.Tables[0].Rows[rowNumber].Delete();
this.UpdNameStudset.Tables[0].Rows[rowNumber].Delete();
UpdSconn=new SqlConnection(UpdStuconnstr);
UpdStuGrdsqlda=new SqlDataAdapter("",UpdSconn);
SqlComm=new SqlCommandBuilder(UpdStuGrdsqlda);
UpdStuGrdsqlda.Update(this.UpdNameStudset.GetChanges(),"HuZhu");
UpdStuGrdsqlda.Update(this.UpdClassStudset.GetChanges(), "HuZhu");
MessageBox.Show("删除成功!","信息");
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString(),"信息"); } } private void UpdateStu_Load()
{ }
private void SaveChg_Click(object sender, System.EventArgs e)
{
try
{
int row=this.UpdStuGrdDg.CurrentCell.RowNumber;
this.UpdStuGrdDg.CurrentCell=new DataGridCell(row+1,0);
if(UpdClassStudset.HasChanges())//如果改动是在根据乡镇检索的结果集上进行的那么,更改该结果集
{
UpdSconn=new SqlConnection(UpdStuconnstr);
UpdStuGrdsqlda=new SqlDataAdapter(this.UpdStustrconnClass,this.UpdSconn);
SqlComm=new SqlCommandBuilder(UpdStuGrdsqlda);
// SqlComm = new SqlDataAdapter
// SqlDataAda = new SqlDataAdapter(UpdStuGrdsqlda);
this.UpdStuGrdsqlda.Update(this.UpdClassStudset.GetChanges(),"HuZhu");
MessageBox.Show("保存修改成功!","信息");
}
else if(UpdNameStudset.HasChanges())//如果改动是在根据户主姓名检索的结果集上进行的那么,更改该结果集
{
UpdSconn=new SqlConnection(UpdStuconnstr);
UpdStuGrdsqlda=new SqlDataAdapter(this.UpdStustrconnName,UpdSconn);
SqlComm=new SqlCommandBuilder(UpdStuGrdsqlda);
UpdStuGrdsqlda.Update(this.UpdNameStudset.GetChanges(),"HuZhu");
MessageBox.Show("保存修改成功!","信息");
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString(),"信息");
}
}
//删除户主记录
private void DelRecord_Click(object sender, System.EventArgs e)
{
int rowNumber=this.UpdStuGrdDg.CurrentCell.RowNumber;
try
{
this.UpdClassStudset.Tables[0].Rows[rowNumber].Delete();
this.UpdNameStudset.Tables[0].Rows[rowNumber].Delete();
UpdSconn=new SqlConnection(UpdStuconnstr);
UpdStuGrdsqlda=new SqlDataAdapter("",UpdSconn);
SqlComm=new SqlCommandBuilder(UpdStuGrdsqlda);
UpdStuGrdsqlda.Update(this.UpdNameStudset.GetChanges(),"HuZhu");
UpdStuGrdsqlda.Update(this.UpdClassStudset.GetChanges(), "HuZhu");
MessageBox.Show("删除成功!","信息");
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString(),"信息"); } } private void UpdateStu_Load()
{ }
{
try
{
int row=this.UpdStuGrdDg.CurrentCell.RowNumber;
this.UpdStuGrdDg.CurrentCell=new DataGridCell(row+1,0);
if(UpdClassStudset.HasChanges())//如果改动是在根据乡镇检索的结果集上进行的那么,更改该结果集
{
UpdSconn=new SqlConnection(UpdStuconnstr);
UpdStuGrdsqlda=new SqlDataAdapter(this.UpdStustrconnClass,this.UpdSconn);
SqlComm=new SqlCommandBuilder(UpdStuGrdsqlda);
//不应该是拿新创建的一个Adpter来更新对UpdClassStudset的更改。
应该谁填充了UpdClassStudset 就拿那个Adpter来更新.
this.UpdStuGrdsqlda.Update(this.UpdClassStudset.GetChanges(),"HuZhu");
MessageBox.Show("保存修改成功!","信息");
}
else if(UpdNameStudset.HasChanges())//如果改动是在根据户主姓名检索的结果集上进行的那么,更改该结果集
{
UpdSconn=new SqlConnection(UpdStuconnstr);
UpdStuGrdsqlda=new SqlDataAdapter(this.UpdStustrconnName,UpdSconn);
SqlComm=new SqlCommandBuilder(UpdStuGrdsqlda);
UpdStuGrdsqlda.Update(this.UpdNameStudset.GetChanges(),"HuZhu");
MessageBox.Show("保存修改成功!","信息");
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString(),"信息");
}
}
//删除户主记录
private void DelRecord_Click(object sender, System.EventArgs e)
{
int rowNumber=this.UpdStuGrdDg.CurrentCell.RowNumber;
try
{
this.UpdClassStudset.Tables[0].Rows[rowNumber].Delete();
this.UpdNameStudset.Tables[0].Rows[rowNumber].Delete();
UpdSconn=new SqlConnection(UpdStuconnstr);
UpdStuGrdsqlda=new SqlDataAdapter("",UpdSconn);
SqlComm=new SqlCommandBuilder(UpdStuGrdsqlda);
UpdStuGrdsqlda.Update(this.UpdNameStudset.GetChanges(),"HuZhu");
UpdStuGrdsqlda.Update(this.UpdClassStudset.GetChanges(), "HuZhu");
MessageBox.Show("删除成功!","信息");
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString(),"信息"); } }