Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click
        Try
            con.query = "SELECT challan.cno, merchant.mname, challan.cdate, challan.total FROM merchant INNER JOIN challan ON merchant.mno = challan.mno WHERE ((challan.cdate Between #" + from.ToString + "# And #" + upto.ToString + "#) AND (challan.mno=" + mno.ToString + "))"

            con.openConnection()
            con.objadp = New OleDbDataAdapter(con.query, con.objcon)
            bulider = New OleDbCommandBuilder(con.objadp)
            dt.Rows.Clear()
            con.objadp.Fill(dt)
            dgvChallanList.DataSource = dt
            dgvChallanList.Columns(0).HeaderText = "Challan No"
            dgvChallanList.Columns(1).HeaderText = "Date"
            dgvChallanList.Columns(2).HeaderText = "Merchant Name"
            dgvChallanList.Columns(3).HeaderText = "Total"
            Dim r As Integer = dt.Rows.Count
            Dim tot As Long = 0
            For i As Integer = 0 To r - 1 Step 1
                tot += dgvChallanList.Rows(i).Cells("Total").Value
            Next
            lblTotal.Text = tot.ToString("00")
        Catch ex As Exception
            MessageBox.Show(ex.Message.ToString)
        Finally
            con.closeConnection()
        End Try
    End Sub



In this Con is a Connection object which can do all the task related to connection and it is a base class also..so that con object can use all the member from that class.
The main Problem is that here Datagridview will not be filled..Can u Help me ???
Posted
Comments
Mahesh Bailwal 7-Oct-13 6:59am    
what error are you getting?
You should debug the code and find out the problem.
Kschuler 7-Oct-13 9:47am    
Is your sql actually pulling back any data? Can you see it when you debug?
member 8888995 8-Oct-13 1:04am    
What is error? Can you paste it here. You set break-point at this method and debug the method. Get query from debug mode and execute it on your database. Where 'dt' is declared?
Techno Cracker 15-Oct-13 16:32pm    
I got the solution friends.There was a date format problem.cause sql take date formate in mm/dd/yyyy and I was giving dd/mm/yyyy.so that output didn't get by me.
Thank You all of You...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900