Thread: Count from DB in visual studio 2010

  1. #1
    Registered User
    Join Date
    Feb 2011
    Location
    UK
    Posts
    1

    Count from DB in visual studio 2010

    I am to finish a program which calculates grades for project students
    The program should also calculate their grade for attendance
    The member of staff who uses the program wants to be able to select a student from a list and see the number of times they have attended meetings.
    So simply choosing student id from combo box i want to see output with how many times this student id was input in the database table and add grade for each meeting and devide it by 6 (max count of meetings). How do i get this info from my database?
    my code so far:

    artial Class _Default

    Inherits System.Web.UI.Page
    'declare a constant to store the number of meetings to be attended
    Const MAX_APPTS As Integer = 6
    'constant to store the text for select a student
    Const NO_STUDENT As String = "(select a student)"


    Protected Sub btnFind_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFind.Click
    'declare a variable to store the appointment reason
    Dim Reason As String
    'declares an instance of the database object allowing us to get the data from the table
    Dim Appointments As New DatabaseTable("appointments.mdb", "select * from appointments", "#PN", "#PW")
    'get the reason
    Reason = Appointments.RecordNumber(0).Item("Reason")
    'display the appointment details in the list concatenating the data
    'lstAppointments.Items.Add(Reason)
    'var to store the appointment count
    Dim ApptCount As Integer
    'var for the student number
    Dim StudentNumber As String
    lblapptCount.Text = ApptCount
    'get the count of appointments
    ApptCount = Appointments.Count
    ApptCount(
    'If statment here to show which student

    ' If StudentNumber Then

    'End If
    ?????????


    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    'if this is the first time the page has been display
    If IsPostBack = False Then
    'populate the student combo
    Call DisplayStudents()
    End If
    End Sub

    Sub DisplayStudents()
    'this sub displays the student numbers in the combo
    'open the table in the database
    Dim Students As New DatabaseTable("appointments.mdb", "select * from Student order by studentnumber", "#PN", "#PW")
    'var to store the student count
    Dim StudentCount As Integer
    'var for the counter
    Dim Count As Integer
    'var for the student number
    Dim StudentNumber As String
    'get the count of students
    StudentCount = Students.Count
    'clear the combo
    cboStudent.Items.Clear()
    'add the default text
    cboStudent.Items.Add(NO_STUDENT)
    'loop through each student
    For Count = 0 To StudentCount - 1
    'get the student no for this student
    StudentNumber = Students.RecordNumber(Count).Item("StudentNumber")
    'add it to the combo
    cboStudent.Items.Add(StudentNumber)
    Next
    End Sub

    Protected Sub cboStudent_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboStudent.SelectedIndexChanged

    End Sub
    End Class

    help please

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Is this visual basic? Because it ain't C/C++/C#. You would probably have better luck getting a correct (and good) answer on a forum dedicated to Visual Basic (or whatever language that is).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Visual Studio 2010 coming for Mac OS X
    By DavidP in forum General Discussions
    Replies: 5
    Last Post: 05-26-2011, 09:49 AM
  2. has anyone used wiiYourself! ?
    By JCML in forum C++ Programming
    Replies: 0
    Last Post: 11-09-2010, 01:06 PM
  3. Visual Studio 2010 Express vs 2005 Standard
    By micahharwell in forum Windows Programming
    Replies: 6
    Last Post: 06-13-2010, 07:45 AM
  4. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  5. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM