Thread thread1=new Thread(new ThreadStart(db));
  thread1.Start();
    
  thread1.Join();//加上这句试试  dg.DataSource=ds;    
  dg.Refresh();