ukfreak 0 Newbie Poster

Hi,

I need a very urgent help.
My requirements is, I need to display my data in a datagriedview on monthly basis only. I have done the retrieving of the data from sql server to the datagriedview. But how do i show it only on monthly basis?

Regards,

Malini

Imports System.Data.SqlClient


Public Class Form1

Dim myconnection As SqlConnection
Dim mycommand As SqlDataReader
Dim dt As New DataTable
Dim da As New SqlDataAdapter
Dim ds As New DataSet

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Close()
End Sub


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

myconnection = GetConnect()
myconnection.Open()


dgViewCustomer.Rows.Add(dgViewCustomer)
dgViewCustomer.Rows.Add(dgViewCustomer)
dgViewCustomer.Rows.Add(dgViewCustomer)

dgViewRunner.Rows.Add(dgViewRunner)
dgViewRunner.Rows.Add(dgViewRunner)
dgViewRunner.Rows.Add(dgViewRunner)

dgViewIns.Rows.Add(dgViewIns)
dgViewIns.Rows.Add(dgViewIns)
dgViewIns.Rows.Add(dgViewIns)
dgViewIns.Rows.Add(dgViewIns)


mycommand = New SqlCommand(
"SELECT COUNT(Q1) FROM customerservice WHERE Q1 = 'Excellent' ", myconnection).ExecuteReader
mycommand.Read()
Dim Ex1 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q1)FROM customerservice WHERE Q1= 'Satisfication' ", myconnection).ExecuteReader
mycommand.Read()
Dim S1 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q1) FROM customerservice WHERE Q1= 'Poor' ", myconnection).ExecuteReader
mycommand.Read()
Dim P1 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q2) FROM customerservice WHERE Q2= 'Excellent' ", myconnection).ExecuteReader
mycommand.Read()
Dim Ex2 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q2) FROM customerservice WHERE Q2= 'Satisfication' ", myconnection).ExecuteReader
mycommand.Read()
Dim S2 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q2) FROM customerservice WHERE Q2= 'Poor' ", myconnection).ExecuteReader
mycommand.Read()
Dim P2 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q3) FROM customerservice WHERE Q3= 'Excellent' ", myconnection).ExecuteReader
mycommand.Read()
Dim Ex3 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q3) FROM customerservice WHERE Q3= 'Satisfication' ", myconnection).ExecuteReader
mycommand.Read()
Dim S3 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q3) FROM customerservice WHERE Q3= 'Poor' ", myconnection).ExecuteReader
mycommand.Read()
Dim P3 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q4) FROM customerservice WHERE Q4= 'Excellent' ", myconnection).ExecuteReader
mycommand.Read()
Dim Ex4 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q4) FROM customerservice WHERE Q4= 'Satisfication' ", myconnection).ExecuteReader
mycommand.Read()
Dim S4 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q4) FROM customerservice WHERE Q4= 'Poor' ", myconnection).ExecuteReader
mycommand.Read()
Dim P4 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q1) FROM runner WHERE Q1 = 'Excellent'", myconnection).ExecuteReader
mycommand.Read()
Dim Ex5 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q1) FROM runner WHERE Q1= 'Satisfication'", myconnection).ExecuteReader
mycommand.Read()
Dim S5 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q1) FROM runner WHERE Q1= 'Poor'", myconnection).ExecuteReader
mycommand.Read()
Dim P5 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q2) FROM runner WHERE Q2 = 'Excellent'", myconnection).ExecuteReader
mycommand.Read()
Dim Ex6 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q2) FROM runner WHERE Q2= 'Satisfication'", myconnection).ExecuteReader
mycommand.Read()
Dim S6 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q2) FROM runner WHERE Q2= 'Poor'", myconnection).ExecuteReader
mycommand.Read()
Dim P6 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q3) FROM runner WHERE Q3 = 'Excellent'", myconnection).ExecuteReader
mycommand.Read()
Dim Ex7 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q3) FROM runner WHERE Q3= 'Satisfication'", myconnection).ExecuteReader
mycommand.Read()
Dim S7 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q3) FROM runner WHERE Q3= 'Poor'", myconnection).ExecuteReader
mycommand.Read()
Dim P7 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q4) FROM runner WHERE Q4= 'Excellent'", myconnection).ExecuteReader
mycommand.Read()
Dim Ex8 = mycommand.Item(0)
mycommand.Close()
mycommand = New SqlCommand(
"SELECT COUNT(Q4) FROM runner WHERE Q4= 'Satisfaction'", myconnection).ExecuteReader
mycommand.Read()
Dim S8 = mycommand.Item(0)

mycommand.Close()
mycommand = New SqlCommand(
"SELECT COUNT(Q4) FROM runner WHERE Q4= 'Poor'", myconnection).ExecuteReader
mycommand.Read()
Dim P8 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q1) FROM instructor WHERE Q1 = 'Excellent'", myconnection).ExecuteReader
mycommand.Read()
Dim Ex9 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q1) FROM instructor WHERE Q1= 'Satisfication'", myconnection).ExecuteReader
mycommand.Read()
Dim S9 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q2) FROM instructor WHERE Q1= 'Poor'", myconnection).ExecuteReader
mycommand.Read()
Dim P9 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q2) FROM instructor WHERE Q2 = 'Excellent'", myconnection).ExecuteReader
mycommand.Read()
Dim Ex10 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q2) FROM instructor WHERE Q2= 'Satisfication'", myconnection).ExecuteReader
mycommand.Read()
Dim S10 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q2) FROM instructor WHERE Q2= 'Poor'", myconnection).ExecuteReader
mycommand.Read()
Dim P10 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q3) FROM instructor WHERE Q3 = 'Excellent'", myconnection).ExecuteReader
mycommand.Read()
Dim Ex11 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q3) FROM instructor WHERE Q3= 'Satisfication'", myconnection).ExecuteReader
mycommand.Read()
Dim S11 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q3) FROM instructor WHERE Q3= 'Poor'", myconnection).ExecuteReader
mycommand.Read()
Dim P11 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q4) FROM instructor WHERE Q4 = 'Excellent'", myconnection).ExecuteReader
mycommand.Read()
Dim Ex12 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q4) FROM instructor WHERE Q4= 'Satisfication'", myconnection).ExecuteReader
mycommand.Read()
Dim S12 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q4) FROM instructor WHERE Q4= 'Poor'", myconnection).ExecuteReader
mycommand.Read()
Dim P12 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q5) FROM instructor WHERE Q5= 'Excellent'", myconnection).ExecuteReader
mycommand.Read()
Dim Ex13 = mycommand.Item(0)
mycommand.Close()
mycommand = New SqlCommand(
"SELECT COUNT(Q5) FROM instructor WHERE Q5= 'Satisfication'", myconnection).ExecuteReader
mycommand.Read()
Dim S13 = mycommand.Item(0)
mycommand.Close()

mycommand = New SqlCommand(
"SELECT COUNT(Q5) FROM instructor WHERE Q5= 'Poor'", myconnection).ExecuteReader
mycommand.Read()
Dim P13 = mycommand.Item(0)
mycommand.Close()


da = New SqlDataAdapter(
"SELECT Name,mykad,phone,lecturer,B,B2,D,E,H,I,GDL,PSV,Date FROM student ORDER by Date, lecturer", myconnection)
da.Fill(dt)
dgViewStudent.DataSource = dt


dgViewStudent.AutoSizeColumnsMode = _
DataGridViewAutoSizeColumnsMode.AllCells


dgViewCustomer.Rows(0).Cells(0).Value = Ex1
dgViewCustomer.Rows(0).Cells(1).Value = S1
dgViewCustomer.Rows(0).Cells(2).Value = P1
dgViewCustomer.Rows(1).Cells(0).Value = Ex2
dgViewCustomer.Rows(1).Cells(1).Value = S2
dgViewCustomer.Rows(1).Cells(2).Value = P2
dgViewCustomer.Rows(2).Cells(0).Value = Ex3
dgViewCustomer.Rows(2).Cells(1).Value = S3
dgViewCustomer.Rows(2).Cells(2).Value = P3
dgViewCustomer.Rows(3).Cells(0).Value = Ex4
dgViewCustomer.Rows(3).Cells(1).Value = S4
dgViewCustomer.Rows(3).Cells(2).Value = P4

dgViewRunner.Rows(0).Cells(0).Value = Ex5
dgViewRunner.Rows(0).Cells(1).Value = S5
dgViewRunner.Rows(0).Cells(2).Value = P5
dgViewRunner.Rows(1).Cells(0).Value = Ex6
dgViewRunner.Rows(1).Cells(1).Value = S6
dgViewRunner.Rows(1).Cells(2).Value = P6
dgViewRunner.Rows(2).Cells(0).Value = Ex7
dgViewRunner.Rows(2).Cells(1).Value = S7
dgViewRunner.Rows(2).Cells(2).Value = P7
dgViewRunner.Rows(3).Cells(0).Value = Ex8
dgViewRunner.Rows(3).Cells(1).Value = S8
dgViewRunner.Rows(3).Cells(2).Value = P8

dgViewIns.Rows(0).Cells(0).Value = Ex9
dgViewIns.Rows(0).Cells(1).Value = S9
dgViewIns.Rows(0).Cells(2).Value = P9
dgViewIns.Rows(1).Cells(0).Value = Ex10
dgViewIns.Rows(1).Cells(1).Value = S10
dgViewIns.Rows(1).Cells(2).Value = P10
dgViewIns.Rows(2).Cells(0).Value = Ex11
dgViewIns.Rows(2).Cells(1).Value = S11
dgViewIns.Rows(2).Cells(2).Value = P11
dgViewIns.Rows(3).Cells(0).Value = Ex12
dgViewIns.Rows(3).Cells(1).Value = S1
dgViewIns.Rows(3).Cells(2).Value = P12
dgViewIns.Rows(4).Cells(0).Value = Ex13
dgViewIns.Rows(4).Cells(1).Value = S3
dgViewIns.Rows(4).Cells(2).Value = P13

End Sub

End Class

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.