//*************************遍历dataGrid行更新数据******************************************
private void UpdateFromDataGrid()
{
string update_SQL="";
//开始更新
System.Data.SqlClient.SqlConnection conn_update=new SqlConnection();
conn_update.Close();
conn_update.ConnectionString=conntSQL;
conn_update.Open();
System.Data.SqlClient.SqlCommand comm_update=new SqlCommand();
comm_update.Connection=conn_update;
System.Data.SqlClient.SqlDataAdapter da_update=new SqlDataAdapter();
da_update.UpdateCommand=comm_update;
//遍历dataGrid所有数据并修改
for(int i=0;i<=dataGrid1.VisibleRowCount-2;i++)
{
update_SQL="update Client_Manage set Client_Name='"+dataGrid1[i,1].ToString()+"',Client_Phone='"+dataGrid1[i,2].ToString()+"',Client_Address='"+dataGrid1[i,3].ToString()+"' where Client_ID="+dataGrid1[i,0].ToString();
comm_update.CommandText=update_SQL;
comm_update.ExecuteNonQuery();
}
//关闭连接节约网络资源
conn_update.Close();
}