title: When large number of records in Database,it throws error "Operation has been cancelled by the user" in vb.net
body: <p>I want to retrieve records from DB2 and display the records in DataGridView in VB.net. If number of records is less it works fine.</p>
  
  <p>But if the database tabe has large number of records it throws error "Operation has been cancelled by the user".
  Can any one help please me...</p>
  
  <p>My code is </p>
  
  <pre><code>    Dim strSQL As String
  
      Dim myConn, myCommand, rs As Object
  
      DataGridView1.DataSource = Nothing
      rs = CreateObject("ADODB.Recordset")
      Const DB_CONNECT_STRING = "Provider=MSDASQL.1;Persist Security Info=False;User ID=cpa5k;Data Source=NP1;DSN=NP1;UID=user;PASSWORD=pass;SDSN=Default;HST=sysplex.com;PRT=4101;Initial Catalog=QA1MM;"
      myConn = CreateObject("ADODB.Connection")
      myCommand = CreateObject("ADODB.Command")
      myConn.Open(DB_CONNECT_STRING)
      myCommand.ActiveConnection = myConn
      strSQL = " query "
      rs.Open(strSQL, myConn)
      Dim myDA As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter
      Dim myDS As DataSet = New DataSet
      myDA.Fill(myDS, rs, "MyTable")
      DataGridView1.DataSource = myDS.Tables(0)
      DataGridView1.Refresh()
      myConn.Close()
  </code></pre>
  
  <p>The Error message displayed is:</p>
  
  <blockquote>
    <p>See the end of this message for details on invoking  just-in-time
    (JIT) debugging instead of this dialog box.</p>
    
    <p><em><strong></em>**<em>*</em>**<em></strong> Exception Text <strong></em>**<em>*</em>****</strong> System.Runtime.InteropServices.COMException (0x800A0E80): Operation
    has been cancelled by the user.   </p>
    
    <p>at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object
    o, Type objType, String name, Object[] args, String[] paramnames,
    Boolean[] CopyBack, Boolean IgnoreReturn)<br>
    at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object
    Instance, Type Type, String MemberName, Object[] Arguments, String[]
    ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean
    IgnoreReturn)    at WindowsApplication2.Form1.Button4_Click(Object
    sender, EventArgs e)<br>
    at System.Windows.Forms.Control.OnClick(EventArgs e)<br>
    at System.Windows.Forms.Button.OnClick(EventArgs e)<br>
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)<br>
    at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons
    button, Int32 clicks)<br>
    at System.Windows.Forms.Control.WndProc(Message&amp; m)<br>
    at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)<br>
    at System.Windows.Forms.Button.WndProc(Message&amp; m)<br>
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp;
    m)    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
    msg, IntPtr wparam, IntPtr lparam)</p>
  </blockquote>
  
  <p>The query which i am running is :</p>
  
  <pre><code>SELECT   A.MVNDR_NBR                     
         ,A.MER_DEPT_NBR                  
        ,C.BYO_NBR                       
        ,B.MKT_NBR                       
        ,D.SKU_NBR                       
          ,A.STR_NBR                       
          ,B.BU_ID                         
          ,COALESCE(D.MIN_EFF_OH_QTY,0)    
          ,COALESCE(D.TRGT_OH_QTY,0)       
          ,D.THRH_BUOM_QTY_PCT             
          ,COALESCE(E.OH_QTY,0)            
          ,COALESCE(E.CHG_OH_QTY,0)        
          ,COALESCE(E.OO_QTY,0)            
          ,E.SKU_VLCTY_CD                  
          ,D.LEAD_TM_DAYS                  
          ,D.REV_TM_DAYS_CNT               
          ,COALESCE(D.SFTY_STK_DAYS,0)     
           ,D.ADJ_ASW_QTY                      
           ,D.MAX_INV_QTY                      
           ,D.TOT_PLNG_OVRD_DAYS               
           ,COALESCE(D.MIN_OH_QTY_DAYS,0)      
           ,F.CURR_DSVC_TYP_CD                 
           ,G.CURR_RMETH_CD                    
           ,F.DCHNL_DC_NBR                     
           ,COALESCE(F.BUY_MIN_QTY,0)          
           ,F.BUY_UOM_QTY                      
           ,COALESCE(E.CORD_ALLOC_QTY,0)       
           ,COALESCE(E.CORD_RSVD_QTY,0)          FROM     PO_AUTO_HORD_STRMV A               
           ,STR                B               
           ,MKT                C               
           ,MVNDR_SKU_STR      F               
           ,SKU_STR_LIST       G                
          ,PO_AUTO_HORD_PARM  D                   LEFT     OUTER JOIN                            
           STRSK_OH_EOO       E                   ON       E.STR_NBR        = D.STR_NBR           AND      E.SKU_NBR        = D.SKU_NBR           WHERE    A.PO_WK_DAY_NBR  = 4   AND      A.EFF_BGN_DT    &lt;= '2011-09-22' AND      A.EFF_END_DT     &gt; '2011-09-22'        AND      D.STR_NBR        = A.STR_NBR           AND      D.MVNDR_NBR      = A.MVNDR_NBR         AND      D.MER_DEPT_NBR   = A.MER_DEPT_NBR      AND      B.STR_NBR        = A.STR_NBR           AND      B.STR_OPEN_DT &lt;= '2011-09-22'       AND      C.MKT_NBR        = B.MKT_NBR           AND      F.MVNDR_NBR      = A.MVNDR_NBR         AND      F.MER_DEPT_NBR   = A.MER_DEPT_NBR      AND      F.SKU_NBR        = D.SKU_NBR            AND      F.STR_NBR        = D.STR_NBR            AND      G.SKU_NBR        = D.SKU_NBR            AND      G.STR_NBR   
  = D.STR_NBR            AND      F.OK_TO_ORD_FLG  = 'Y'                  AND      G.SKU_STAT_CD IN (100, 200)             AND      G.SOS_IND    IN ('V','B')           AND      F.CURR_DSVC_TYP_CD IN (1, 3)           ORDER BY A.MVNDR_NBR                            
          ,C.BYO_NBR                              
          ,B.MKT_NBR                              
          ,F.DCHNL_DC_NBR                         
          ,F.CURR_DSVC_TYP_CD                     
          ,D.SKU_NBR                              
          ,A.STR_NBR                               WITH  UR
  </code></pre>