Datagrid Problem- Run time error'6'- overflow

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lucky13
    New Member
    • Aug 2007
    • 24

    Datagrid Problem- Run time error'6'- overflow

    Dear All,

    I m connecting my sql data with the data grid, but not all columns only particular columns. having certain conditions, but it is showing the error as Runtime Error '6- overflow...

    please help me....

    Regards
    Lucky13
  • nev
    Contributor
    • Oct 2007
    • 251

    #2
    dataadapter = New MySqlDataAdapte r("SELECT column1,column2 ,column3 FROM tablename", connection)

    dataadapter.Fil l(datatable)

    datagridview.da tasource = datatable

    or

    dataadapter = New MySqlDataAdapte r("SELECT * FROM tablename", connection)

    dataadapter.Fil l(datatable)

    datatable.colum n(column).clomn mapping = columnmapping.h idden

    datagridview.da tasource = datatable

    or

    dataadapter = New MySqlDataAdapte r("SELECT * FROM tablename", connection)

    dataadapter.Fil l(datatable)

    datagridview.da tasource = datatable

    if lcase(datagridv iew.column(colu mn).name.tostri ng) = "column" then
    datagridview.co lumn(column).vi sible = false
    end if

    Comment

    • lucky13
      New Member
      • Aug 2007
      • 24

      #3
      Hello Nev,

      thanks for the immediate reply, but i m sorry , i typed the wrong database as mysql, actually it is sql server 2000.



      Originally posted by nev
      dataadapter = New MySqlDataAdapte r("SELECT column1,column2 ,column3 FROM tablename", connection)

      dataadapter.Fil l(datatable)

      datagridview.da tasource = datatable

      or

      dataadapter = New MySqlDataAdapte r("SELECT * FROM tablename", connection)

      dataadapter.Fil l(datatable)

      datatable.colum n(column).clomn mapping = columnmapping.h idden

      datagridview.da tasource = datatable

      or

      dataadapter = New MySqlDataAdapte r("SELECT * FROM tablename", connection)

      dataadapter.Fil l(datatable)

      datagridview.da tasource = datatable

      if lcase(datagridv iew.column(colu mn).name.tostri ng) = "column" then
      datagridview.co lumn(column).vi sible = false
      end if

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        Hi,

        What SQL Statement you have used for the data adapter..?

        Regards
        Veena

        Comment

        • lucky13
          New Member
          • Aug 2007
          • 24

          #5
          Hello,

          Sorry, i m wrongly typed the my sql, i m using sql server 2000

          Comment

          • QVeen72
            Recognized Expert Top Contributor
            • Oct 2006
            • 1445

            #6
            Hi,

            My question was.. Whatever backend database...,
            What is the SQL Statement ...?

            and VB6 or VB.Net..?

            REgards
            Veena
            Last edited by Killer42; Oct 17 '07, 10:34 AM.

            Comment

            • lucky13
              New Member
              • Aug 2007
              • 24

              #7
              Hello

              i m usiing VB6,

              here i create column hearder & my sql statement is as follow

              sql = "Select Cust_Code, sum(Net_Payment )as Net_Payment from Payment_Paid_St atus where Payment_Month>= '" & strmonth & "' And Payment_Month= '" & strmonth_1 & "' and Tool_Category=' " & cmbcategory.Tex t & "' group by Cust_code"
              rsdetails.Open sql, con, adOpenDynamic, adLockBatchOpti mistic


              Regards,


              Originally posted by QVeen72
              Hi,

              My question was.. Whatever backend database...,
              What is the SQL Statement ...?

              and VB6 or VB.Net..?

              REgards
              Veena

              Comment

              • QVeen72
                Recognized Expert Top Contributor
                • Oct 2006
                • 1445

                #8
                Originally posted by lucky13
                Hello

                i m usiing VB6,

                here i create column hearder & my sql statement is as follow

                sql = "Select Cust_Code, sum(Net_Payment )as Net_Payment from Payment_Paid_St atus where Payment_Month>= '" & strmonth & "' And Payment_Month= '" & strmonth_1 & "' and Tool_Category=' " & cmbcategory.Tex t & "' group by Cust_code"
                rsdetails.Open sql, con, adOpenDynamic, adLockBatchOpti mistic


                Regards,
                Hi,
                Check these:
                does net_payment have Null..?

                "Payment_Month> ='" & strmonth
                above means you are checking for Greater, but strmonth is text...
                same for strMonth1 (are you sure data types match..?)


                Regards
                Veena

                Comment

                • lucky13
                  New Member
                  • Aug 2007
                  • 24

                  #9
                  Hello Veena,
                  Net_payment is not null, & in another form i used the same strmonth & it works..

                  First time i am trying to connect grid to sql data...

                  i think i m doung something worng while connecting to grid... see the whole code for connecting to grid...

                  Code:
                  Private Sub Connectgrid()
                  
                  Dim rsdetails As New ADODB.Recordset
                  Dim i As Integer
                  
                  con.Open
                  
                  Call Month_Conv
                  
                  sql = "Select Cust_Code, sum(Net_Payment)as Net_Payment from Payment_Paid_Status where Payment_Month>='" & strmonth & "' And Payment_Month= '" & strmonth_1 & "' and Tool_Category='" & cmbcategory.Text & "' group by Cust_code"
                  
                  rsdetails.Open sql, con, adOpenDynamic, adLockBatchOptimistic
                  
                  If rsdetails.RecordCount > 0 Then
                      rsdetails.MoveNext
                  End If
                  
                  If Not (rsdetails.EOF And rsdetails.BOF) Then
                  
                      With rsdetails
                  
                          dgpaydetails.Row = !Cust_Code // [B]here i am facing the problem.....[/B]
                          dgpaydetails.Row = !Net_Breaks
                  
                      End With
                  
                  End If
                  
                  
                  End Sub
                  Regards

                  Comment

                  • QVeen72
                    Recognized Expert Top Contributor
                    • Oct 2006
                    • 1445

                    #10
                    Originally posted by lucky13
                    Hello Veena,
                    Net_payment is not null, & in another form i used the same strmonth & it works..

                    First time i am trying to connect grid to sql data...

                    i think i m doung something worng while connecting to grid... see the whole code for connecting to grid...

                    Code:
                    Private Sub Connectgrid()
                    
                    Dim rsdetails As New ADODB.Recordset
                    Dim i As Integer
                    
                    con.Open
                    
                    Call Month_Conv
                    
                    sql = "Select Cust_Code, sum(Net_Payment)as Net_Payment from Payment_Paid_Status where Payment_Month>='" & strmonth & "' And Payment_Month= '" & strmonth_1 & "' and Tool_Category='" & cmbcategory.Text & "' group by Cust_code"
                    
                    rsdetails.Open sql, con, adOpenDynamic, adLockBatchOptimistic
                    
                    If rsdetails.RecordCount > 0 Then
                        rsdetails.MoveNext
                    End If
                    
                    If Not (rsdetails.EOF And rsdetails.BOF) Then
                    
                        With rsdetails
                    
                            dgpaydetails.Row = !Cust_Code // [B]here i am facing the problem.....[/B]
                            dgpaydetails.Row = !Net_Breaks
                    
                        End With
                    
                    End If
                    
                    
                    End Sub
                    Regards
                    Hello,

                    To display Recordset Results to DataGrid, all you have to do is :

                    [code=vb]
                    rsdetails.Curso rLocation = adUseClient
                    rsdetails.Open sql, con, adOpenStatic, adLockReadOnly
                    With dgpaydetails
                    .DataMember = ""
                    Set .DataSource = rsdetails
                    .Refresh
                    End With
                    [/code]

                    Regards
                    Veena

                    Comment

                    • lucky13
                      New Member
                      • Aug 2007
                      • 24

                      #11
                      Hello,

                      thanks veena, it is working but if u see my query in that i have mention sum function with group by clause. but as per u r solution recordset is showing individual net amount, & that to for the last record for that particular customer.

                      means for particular customer there are three records & i want net-amount of that three records, but by this i am getting only the amount to third record.
                      sorry for troubling so much...

                      Regards


                      Originally posted by QVeen72
                      Hello,

                      To display Recordset Results to DataGrid, all you have to do is :

                      [code=vb]
                      rsdetails.Curso rLocation = adUseClient
                      rsdetails.Open sql, con, adOpenStatic, adLockReadOnly
                      With dgpaydetails
                      .DataMember = ""
                      Set .DataSource = rsdetails
                      .Refresh
                      End With
                      [/code]

                      Regards
                      Veena

                      Comment

                      • QVeen72
                        Recognized Expert Top Contributor
                        • Oct 2006
                        • 1445

                        #12
                        Hi,

                        I have not changed the SQL Query..
                        Did you Run the Query at Back end and checked..?


                        Regards
                        Veena

                        Comment

                        • lucky13
                          New Member
                          • Aug 2007
                          • 24

                          #13
                          Hi,

                          thanks veena, when i checked in the backend there , but there is also same result, only showing last record. then i checked i query , there is one mistake that in near strmonth_1 i have not mentioned the less than sign........

                          thanks a lot.

                          can u do one more favour for me.... if i want to add user data through data grid... in adding one more column ,, so which property i have to use...ADDNEWMOD E or ALLOW ADD NEW.....

                          thanks a lot once again.......... .

                          Regards
                          Lucky13


                          Originally posted by QVeen72
                          Hi,

                          I have not changed the SQL Query..
                          Did you Run the Query at Back end and checked..?


                          Regards
                          Veena

                          Comment

                          • ninjamynci
                            New Member
                            • Oct 2007
                            • 1

                            #14
                            Originally posted by QVeen72
                            Hello,

                            To display Recordset Results to DataGrid, all you have to do is :

                            [code=vb]
                            rsdetails.Curso rLocation = adUseClient
                            rsdetails.Open sql, con, adOpenStatic, adLockReadOnly
                            With dgpaydetails
                            .DataMember = ""
                            Set .DataSource = rsdetails
                            .Refresh
                            End With
                            [/code]

                            Regards
                            Veena
                            Thanks Veena,
                            You've solved my problem too without me even having to ask!

                            Cheers
                            Ninj

                            Comment

                            Working...