SqlDataAdapter更新数据库,并发的问题
问大家个问题 
 我在用SqlDataAdapter更新数据库的时候,如果出现并发的情况会有许多相同的数据,怎么处理啊
------解决方案-------------------- "如果出现并发的情况会有许多相同的数据 "   
 不明白什么意思?什么时候出现并发,什么相同的数据?
------解决方案--------------------有没可能是update时造成的数据重复
------解决方案--------------------DataSet ds = new DataSet(); 
             SqlConnection scon = new SqlConnection( "server=;uid=sa;pwd=123;database=aaa "); 
             SqlDataAdapter da = new SqlDataAdapter( "select * from ccc ", scon); 
             SqlCommandBuilder cb = new SqlCommandBuilder(da); 
             scon.Open(); 
             da.Update(ds,  "ccc "); 
             scon.Close();     
 用SqlCommandBuilder  实现批量更新     
    1.功能:       
      可以实现你对DataSet在UI层做任意操作后,直接丢给这个方法,这个方法就可以自动把你的修改更  新到数  据库中,而没必要每次都更新到     
      数据库     
    2.使用方法   
    public  DataSetUpdateByDataSet(DataSet  ds,string  strTblName,string  strConnection)   
    {   
            SqlConnection    conn  =  new  SqlConnection(strConnection));                        
          SqlDataAdapter  myAdapter  =  new  SqlDataAdapter();   
          SqlCommand  myCommand  =  new  SqlCommand( "select  *  from   "+strTblName),(SqlConnection)  conn);           
          myAdapter.SelectCommand  =  myCommand;   
          SqlCommandBuilder  myCommandBuilder  =  new  SqlCommandBuilder(myAdapter);             
    try     
            {         
                              lock(this)                        //处理并发情况(分布式情况)     
                            {     
                              myAdapter.Update(ds,strTblName);         
                            }     
            }            
    catch(Exception  err)   
 {     
      conn.Close();         
      throw  new  BusinessException(err);   
 }     
        return  ds;        //数据集的行状态在更新后会都变为:  UnChange,在这次更新后客户端要用返回的ds     
 }     
 或     
 public  DataSet  UpdateByDataSet(DataSet  ds,string  strTblName,string  strConnection)   
    {                   
            SqlConnection    conn  =  new  SqlConnection(strConnection));                     
            SqlCommand  myCommand  =  new  SqlCommand( "select  *  from   "+strTblName),(SqlConnection)  conn);             
            SqlDataAdapter  myAdapter  =  new  SqlDataAdapter(myCommand  );           
            SqlCommandBuilder  myCommandBuilder  =  new  SqlCommandBuilder(myAdapter);                            
            myAdapter.InsertCommand  =  myCommandBuilder  .GetInsertCommand();     
            myAdapter.UpdateCommand  =  myCommandBuilder  .GetUpdateCommand();     
          myAdapter.DeleteCommand  =  myCommandBuilder  .GetDeleteCommand();     
      try     
    {     
                lock(this)                                                            //处理并发情况(分布式情况)     
              {     
                            conn.Open();     
                            myAdapter.Update(ds,strTblName);         
                            conn.Close();     
              }          
                  return  ds;        //数据集的行状态在更新后会都变为:  UnChange,在这次更新后客户端要用返回的ds  }   
 catch(Exception  err)   
 {       
            conn.Close();     
            throw  new  BusinessException(err);   
 }   
 }     
 直接调用这两个方法的任意一个就OK啦,说明的一点是select  *  from   "+strTblName是一定要的,   
 作用大家也应该想到了,主要是告诉  SqlDataAdapter更新哪个