0
votes

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.

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...

My code is

    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()

The Error message displayed is:

See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.

***** Exception Text ******* System.Runtime.InteropServices.COMException (0x800A0E80): Operation has been cancelled by the user.

at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
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)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

The query which i am running is :

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    <= '2011-09-22' AND      A.EFF_END_DT     > '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 <= '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
1
What happens if you run the query directly in the DB platform (instead of through code). Does it work? If not, you need to fix the query first.JohnFx
If i directly run thru the DB platform..it is working...Query is correct only....user1271146
What line is throwing the error?JohnFx
I have updated the error in the question....Its giving error in "rs.Open(strSQL, myConn)" lineuser1271146
Why are you using COM ADODB in VB.NET instead of the objects in the System.Data.OleDb namespace?HardCode

1 Answers

0
votes

We've had this issue once before, and the work-around is to increase the QUERYTIMEOUTINTERVAL setting (or set to zero - which may make other trouble of its own) in the DB2 Client configuration.

(See http://www.ibm.com/developerworks/forums/message.jspa?messageID=13894231 )


BTW, HardCode is right, there really is no reason to use ADODB (especially via CreateObject and late binding!) when .NET provides (the superior, IMO) ADO.NET and OLEDB.