hello all,
kindly help me for this
i have one form with datagridview in vb.net and 5 textbox
for filing GDV i am using code:

Dim a As String = txttable.Text
        DataAdapter1 = New OleDbDataAdapter("Select * From " & txttable.Text & " where [pay_year] = '" & cmbSyear.Text & "' AND" _
                                            & "[pay_month] = '" & cmbSmonth.Text & "' ORDER BY payID", Con)
        DataSet2.Clear()
        DataAdapter1.Fill(DataSet2, "" & txttable.Text & "")
        DGVspandey.DataSource = DataSet2
        DGVspandey.DataMember = "" & txttable.Text & ""
        DGVspandey.Refresh()

after that databinding with this:

lblgrossS.DataBindings.Clear()
lblgrossS.DataBindings.Add("Text", DataSet2, ("'" & txttable.Text & "'")(CInt(".grand_total "))).ToString()

but getting error
Conversion from string ".grand_total " to type 'Integer' is not valid.

kindly help me for this
thanks in advence

You are trying to cast the string ".grand_total " to an integer. It can't be done.

Well, CInt with a string is not possible. Try CChar(), or replace ".grand_total " with some Int value.

no its not working
i change it to:
lblgrossS.DataBindings.Add("Text", DataSet2, ("'" & txttable.Text & "'")(AscW(CChar(".grand_total "))).ToString())
but geetting error:- Index was outside the bounds of the array.
please help me for this
thanks for respond

Same problem except this time you are trying to convert a string to a char. Perhaps you could explain what you are trying to accomplish with

lblgrossS.DataBindings.Add("Text", DataSet2, ("'" & txttable.Text & "'")(CInt(".grand_total "))).ToString()

thanks for response
i solved it and showing code here if some one want to use it:

Dim Connection As New OleDb.OleDbConnection(CnString)
        Dim ds As New DataSet
        Dim sql As String = "Select * From " & txttable.Text & " where [pay_year] = '" & cmbSyear.Text & "' AND" _
                                            & "[pay_month] = '" & cmbSmonth.Text & "' ORDER BY payID"
        Dim da As OleDbDataAdapter = New OleDbDataAdapter(sql, Connection)
        Try
            da.Fill(ds, "'" & txttable.Text & "'")
        Finally
            da.Dispose()
        End Try
        '''''''''''data binding clear'''''''''''''''''''
        lblgrossS.DataBindings.Clear()
        lbldeduction.DataBindings.Clear()
        lblnetpay.DataBindings.Clear()
        lblbasicpay.DataBindings.Clear()
        lblDA.DataBindings.Clear()
        '''''''''''''connect data binding'''''''''''''''''''''
        Me.lblgrossS.DataBindings.Add("Text", ds.Tables(0), "grand_total")
        Me.lbldeduction.DataBindings.Add("Text", ds.Tables(0), "total_deduction")
        Me.lblnetpay.DataBindings.Add("Text", ds.Tables(0), "amount_pay")
        Me.lblbasicpay.DataBindings.Add("Text", ds.Tables(0), "basic_pay")
        Me.lblDA.DataBindings.Add("Text", ds.Tables(0), "calculated_DA")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.